diff --git a/src/js/pagestore.js b/src/js/pagestore.js index 4ddc73b60..615515a72 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -41,10 +41,6 @@ const µb = µBlock; /******************************************************************************/ -// To mitigate memory churning -const netFilteringCacheJunkyard = []; -const netFilteringCacheJunkyardMax = 10; - const NetFilteringResultCache = class { constructor() { this.init(); @@ -58,14 +54,6 @@ const NetFilteringResultCache = class { return this; } - dispose() { - this.empty(); - if ( netFilteringCacheJunkyard.length < netFilteringCacheJunkyardMax ) { - netFilteringCacheJunkyard.push(this); - } - return null; - } - rememberResult(fctxt, result) { if ( fctxt.tabId <= 0 ) { return; } if ( this.results.size === 0 ) { @@ -155,10 +143,7 @@ const NetFilteringResultCache = class { } static factory() { - const entry = netFilteringCacheJunkyard.pop(); - return entry !== undefined - ? entry.init() - : new NetFilteringResultCache(); + return new NetFilteringResultCache(); } }; @@ -218,6 +203,7 @@ const PageStore = class { this.journalTimer = null; this.journalLastCommitted = this.journalLastUncommitted = undefined; this.journalLastUncommittedURL = undefined; + this.netFilteringCache = NetFilteringResultCache.factory(); this.init(tabId, context); } @@ -261,7 +247,6 @@ const PageStore = class { this.popupBlockedCount = 0; this.largeMediaCount = 0; this.largeMediaTimer = null; - this.netFilteringCache = NetFilteringResultCache.factory(); this.internalRedirectionCount = 0; this.extraData.clear(); @@ -327,7 +312,6 @@ const PageStore = class { this.largeMediaTimer = null; } this.disposeFrameStores(); - this.netFilteringCache = this.netFilteringCache.dispose(); this.init(this.tabId, context); return this; } @@ -337,13 +321,13 @@ const PageStore = class { this.title = ''; this.rawURL = ''; this.hostnameToCountMap = null; + this.netFilteringCache.empty(); this.allowLargeMediaElementsUntil = 0; if ( this.largeMediaTimer !== null ) { clearTimeout(this.largeMediaTimer); this.largeMediaTimer = null; } this.disposeFrameStores(); - this.netFilteringCache = this.netFilteringCache.dispose(); if ( this.journalTimer !== null ) { clearTimeout(this.journalTimer); this.journalTimer = null; diff --git a/src/js/tab.js b/src/js/tab.js index d0e64bcb3..ea7286251 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -887,6 +887,7 @@ vAPI.tabs = new vAPI.Tabs(); // https://github.com/chrisaljoudi/uBlock/issues/516 // If context is 'beforeRequest', do not rebind, wait for confirmation. if ( context === 'beforeRequest' ) { + pageStore.netFilteringCache.empty(); return pageStore; }