mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 917489 - Fix an observer leak in about:memory. r=mccr8.
This commit is contained in:
parent
b1a2836e80
commit
939e8198d3
@ -48,12 +48,17 @@ XPCOMUtils.defineLazyGetter(this, "nsGzipConverter",
|
||||
let gMgr = Cc["@mozilla.org/memory-reporter-manager;1"]
|
||||
.getService(Ci.nsIMemoryReporterManager);
|
||||
|
||||
// We need to know about "child-memory-reporter-update" events from child
|
||||
// processes.
|
||||
let gOs = Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService);
|
||||
gOs.addObserver(updateAboutMemoryFromReporters,
|
||||
"child-memory-reporter-update", false);
|
||||
|
||||
let gUnnamedProcessStr = "Main Process";
|
||||
|
||||
let gIsDiff = false;
|
||||
|
||||
let gChildMemoryListener = undefined;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// Forward slashes in URLs in paths are represented with backslashes to avoid
|
||||
@ -115,28 +120,10 @@ function debug(x)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
function addChildObserversAndUpdate(aUpdateFn)
|
||||
{
|
||||
let os = Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService);
|
||||
os.notifyObservers(null, "child-memory-reporter-request", null);
|
||||
|
||||
gChildMemoryListener = aUpdateFn;
|
||||
os.addObserver(gChildMemoryListener, "child-memory-reporter-update", false);
|
||||
|
||||
gChildMemoryListener();
|
||||
}
|
||||
|
||||
function onUnload()
|
||||
{
|
||||
// We need to check if the observer has been added before removing; in some
|
||||
// circumstances (e.g. reloading the page quickly) it might not have because
|
||||
// onLoad might not fire.
|
||||
if (gChildMemoryListener) {
|
||||
let os = Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService);
|
||||
os.removeObserver(gChildMemoryListener, "child-memory-reporter-update");
|
||||
}
|
||||
gOs.removeObserver(updateAboutMemoryFromReporters,
|
||||
"child-memory-reporter-update");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@ -467,7 +454,12 @@ function doMMU()
|
||||
|
||||
function doMeasure()
|
||||
{
|
||||
addChildObserversAndUpdate(updateAboutMemoryFromReporters);
|
||||
// Notify any children that they should measure memory consumption, then
|
||||
// update the page. If any reports come back from children,
|
||||
// updateAboutMemoryFromReporters() will be called again and the page will
|
||||
// regenerate.
|
||||
gOs.notifyObservers(null, "child-memory-reporter-request", null);
|
||||
updateAboutMemoryFromReporters();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user