Bug 1436614 - Report ghost windows in Memory.jsm. r=mconley
authorEric Rahm <erahm@mozilla.com>
Wed, 07 Feb 2018 15:46:57 -0800
changeset 752964 21f73ed97e6a5c9ff968a710da3d7ddb62fce2ca
parent 752963 e3e86c9d1807f3917c0b41aed1c398d3d40182b7
child 752965 fc5cbc7e0d7ff28ed81f802a4973e2e8634cfe61
push id98429
push usermak77@bonardo.net
push dateFri, 09 Feb 2018 10:14:12 +0000
reviewersmconley
bugs1436614
milestone60.0a1
Bug 1436614 - Report ghost windows in Memory.jsm. r=mconley This adds a 'ghosts' field to the object returned by Memory.summary.
toolkit/content/process-content.js
toolkit/modules/Memory.jsm
--- a/toolkit/content/process-content.js
+++ b/toolkit/content/process-content.js
@@ -44,21 +44,23 @@ if (gInContentProcess) {
       if (msg.name != "Memory:GetSummary") {
         return;
       }
       let pid = Services.appinfo.processID;
       let memMgr = Cc["@mozilla.org/memory-reporter-manager;1"]
                      .getService(Ci.nsIMemoryReporterManager);
       let rss = memMgr.resident;
       let uss = memMgr.residentUnique;
+      let ghosts = memMgr.ghostWindows;
       Services.cpmm.sendAsyncMessage("Memory:Summary", {
         pid,
         summary: {
           uss,
           rss,
+          ghosts,
         }
       });
     },
 
     observe(subject, topic, data) {
       switch (topic) {
         case "inner-window-destroyed": {
           // Forward inner-window-destroyed notifications with the
--- a/toolkit/modules/Memory.jsm
+++ b/toolkit/modules/Memory.jsm
@@ -17,20 +17,22 @@ this.Memory = {
    * process.
    * @returns Promise
    * @resolves JS Object
    * An Object in the following format:
    * {
    *   "parent": {
    *     uss: <int>,
    *     rss: <int>,
+   *     ghosts: <int>,
    *   },
    *   <pid>: {
    *     uss: <int>,
    *     rss: <int>,
+   *     ghosts: <int>,
    *   },
    *   ...
    * }
    */
   summary() {
     if (!this._pendingPromise) {
       this._pendingPromise = new Promise((resolve) => {
         this._pendingResolve = resolve;
@@ -60,17 +62,18 @@ this.Memory = {
 
   finish() {
     // Code to gather the USS and RSS values for the parent process. This
     // functions the same way as in process-content.js.
     let memMgr = Cc["@mozilla.org/memory-reporter-manager;1"]
                    .getService(Ci.nsIMemoryReporterManager);
     let rss = memMgr.resident;
     let uss = memMgr.residentUnique;
-    this._summaries.Parent = { uss, rss };
+    let ghosts = memMgr.ghostWindows;
+    this._summaries.Parent = { uss, rss, ghosts };
     this._pendingResolve(this._summaries);
     this._pendingResolve = null;
     this._summaries = null;
     this._pendingPromise = null;
     clearTimeout(this._pendingTimeout);
     Services.ppmm.removeMessageListener("Memory:Summary", this);
   }
 };