зеркало из https://github.com/mozilla/gecko-dev.git
Bug 803575 - Enable preemptive tab zombification in low-memory conditions. r=mfinkle
This commit is contained in:
Родитель
4dfae7eef7
Коммит
4622a2f0dc
|
@ -30,8 +30,8 @@ pref("browser.tabs.remote", false);
|
|||
|
||||
// If a tab has not been active for this long (seconds), then it may be
|
||||
// turned into a zombie tab to preemptively free up memory. -1 disables time-based
|
||||
// zombification (low-memory conditions may still require the tab to be zombified).
|
||||
pref("browser.tabs.zombieTime", -1);
|
||||
// expiration (but low-memory conditions may still require the tab to be zombified).
|
||||
pref("browser.tabs.expireTime", 3600);
|
||||
|
||||
// From libpref/src/init/all.js, extended to allow a slightly wider zoom range.
|
||||
pref("zoom.minPercent", 20);
|
||||
|
|
|
@ -235,6 +235,7 @@ var BrowserApp = {
|
|||
ExternalApps.init();
|
||||
MemoryObserver.init();
|
||||
Distribution.init();
|
||||
Tabs.init();
|
||||
#ifdef MOZ_TELEMETRY_REPORTING
|
||||
Telemetry.init();
|
||||
#endif
|
||||
|
@ -511,6 +512,7 @@ var BrowserApp = {
|
|||
ExternalApps.uninit();
|
||||
MemoryObserver.uninit();
|
||||
Distribution.uninit();
|
||||
Tabs.uninit();
|
||||
#ifdef MOZ_TELEMETRY_REPORTING
|
||||
Telemetry.uninit();
|
||||
#endif
|
||||
|
@ -670,7 +672,7 @@ var BrowserApp = {
|
|||
evt.initUIEvent("TabOpen", true, false, window, null);
|
||||
newTab.browser.dispatchEvent(evt);
|
||||
|
||||
Tabs.zombifyLru();
|
||||
Tabs.expireLruTab();
|
||||
|
||||
return newTab;
|
||||
},
|
||||
|
@ -7709,13 +7711,43 @@ var Tabs = {
|
|||
// of tabs. Each tab has a timestamp associated with it that indicates when
|
||||
// it was last touched.
|
||||
|
||||
_enableTabExpiration: false,
|
||||
|
||||
init: function() {
|
||||
// on low-memory platforms, always allow tab expiration. on high-mem
|
||||
// platforms, allow it to be turned on once we hit a low-mem situation
|
||||
if (Cc["@mozilla.org/xpcom/memory-service;1"].getService(Ci.nsIMemory).isLowMemoryPlatform()) {
|
||||
this._enableTabExpiration = true;
|
||||
} else {
|
||||
Services.obs.addObserver(this, "memory-pressure", false);
|
||||
}
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
if (!this._enableTabExpiration) {
|
||||
// if _enableTabExpiration is true then we won't have this
|
||||
// observer registered any more.
|
||||
Services.obs.removeObserver(this, "memory-pressure");
|
||||
}
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "memory-pressure" && aData != "heap-minimize") {
|
||||
this._enableTabExpiration = true;
|
||||
Services.obs.removeObserver(this, "memory-pressure");
|
||||
}
|
||||
},
|
||||
|
||||
touch: function(aTab) {
|
||||
aTab.lastTouchedAt = Date.now();
|
||||
},
|
||||
|
||||
zombifyLru: function() {
|
||||
let zombieTimeMs = Services.prefs.getIntPref("browser.tabs.zombieTime") * 1000;
|
||||
if (zombieTimeMs < 0) {
|
||||
expireLruTab: function() {
|
||||
if (!this._enableTabExpiration) {
|
||||
return false;
|
||||
}
|
||||
let expireTimeMs = Services.prefs.getIntPref("browser.tabs.expireTime") * 1000;
|
||||
if (expireTimeMs < 0) {
|
||||
// this behaviour is disabled
|
||||
return false;
|
||||
}
|
||||
|
@ -7732,9 +7764,9 @@ var Tabs = {
|
|||
lruTab = tabs[i];
|
||||
}
|
||||
}
|
||||
// if the tab was last touched more than browser.tabs.zombieTime seconds ago,
|
||||
// if the tab was last touched more than browser.tabs.expireTime seconds ago,
|
||||
// zombify it
|
||||
if (lruTab && (Date.now() - lruTab.lastTouchedAt) > zombieTimeMs) {
|
||||
if (lruTab && (Date.now() - lruTab.lastTouchedAt) > expireTimeMs) {
|
||||
MemoryObserver.zombify(lruTab);
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче