Bug 945973 (part 2) - Don't complain if there aren't any "explicit" reports for a process. r=mccr8.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 03 Dec 2013 20:19:41 -0800
changeset 160753 76dbeac4522705453afd2f7201ecacbcb8fc6dd7
parent 160752 c9e9f2940aefaa27bd71b812612f450e89ddd025
child 160754 0a276a083a26ee59a019ac0a61c8b5394aee9adc
push id25848
push usercbook@mozilla.com
push dateTue, 17 Dec 2013 11:46:20 +0000
treeherdermozilla-central@03ff4ad4bc05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs945973
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 945973 (part 2) - Don't complain if there aren't any "explicit" reports for a process. r=mccr8.
toolkit/components/aboutmemory/content/aboutMemory.js
toolkit/components/aboutmemory/tests/test_aboutmemory3.xul
toolkit/components/aboutmemory/tests/test_aboutmemory4.xul
xpcom/base/nsIMemoryReporter.idl
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -1282,22 +1282,24 @@ function appendProcessAboutMemoryElement
 
   appendElementWithText(aP, "h1", "", aProcess);
   appendLink("start", "end", kDownwardsArrow);
 
   // We'll fill this in later.
   let warningsDiv = appendElement(aP, "div", "accuracyWarning");
 
   // The explicit tree.
+  let hasExplicitTree;
   let hasKnownHeapAllocated;
   {
     let treeName = "explicit";
-    let pre = appendSectionHeader(aP, "Explicit Allocations");
     let t = aTrees[treeName];
     if (t) {
+      let pre = appendSectionHeader(aP, "Explicit Allocations");
+      hasExplicitTree = true;
       fillInTree(t);
       // Using the "heap-allocated" reporter here instead of
       // nsMemoryReporterManager.heapAllocated goes against the usual pattern.
       // But the "heap-allocated" node will go in the tree like the others, so
       // we have to deal with it, and once we're dealing with it, it's easier
       // to keep doing so rather than switching to the distinguished amount.
       hasKnownHeapAllocated =
         aDegenerates &&
@@ -1345,21 +1347,23 @@ function appendProcessAboutMemoryElement
   }
   for (let i = 0; i < otherDegenerates.length; i++) {
     let t = otherDegenerates[i];
     let padText = pad("", maxStringLength - t.toString().length, ' ');
     appendTreeElements(pre, t, aProcess, padText);
   }
   appendTextNode(aP, "\n");  // gives nice spacing when we copy and paste
 
-  // Add any warnings about inaccuracies due to platform limitations.
-  // These must be computed after generating all the text.  The newlines give
-  // nice spacing if we copy+paste into a text buffer.
-  appendWarningElements(warningsDiv, hasKnownHeapAllocated,
-                        aHasMozMallocUsableSize);
+  // Add any warnings about inaccuracies in the "explicit" tree due to platform
+  // limitations.  These must be computed after generating all the text.  The
+  // newlines give nice spacing if we copy+paste into a text buffer.
+  if (hasExplicitTree) {
+    appendWarningElements(warningsDiv, hasKnownHeapAllocated,
+                          aHasMozMallocUsableSize);
+  }
 
   appendElementWithText(aP, "h3", "", "End of " + aProcess);
   appendLink("end", "start", kUpwardsArrow);
 }
 
 /**
  * Determines if a number has a negative sign when converted to a string.
  * Works even for -0.
--- a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul
+++ b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul
@@ -224,20 +224,16 @@ 1,024 B (100.0%) -- size\n\
 \n\
 1,024 B (100.0%) -- swap\n\
 └──1,024 B (100.0%) ── a\n\
 \n\
 262,144,000 B ── heap-allocated\n\
 \n\
 End of Main Process (pid NNN)\n\
 Other-only process\n\
-\n\
-WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
-Explicit Allocations\n\
-\n\
 Other Measurements\n\
 \n\
 200,000 B (100.0%) -- a\n\
 ├──100,000 B (50.00%) ── b\n\
 └──100,000 B (50.00%) ── c\n\
 \n\
 500,000 B ── heap-allocated\n\
 \n\
@@ -285,40 +281,28 @@ Explicit Allocations\n\
 \n\
 Other Measurements\n\
 \n\
 3,000 B ── canvas-2d-pixel-bytes [2] [+]\n\
  -100 B ── foobar [-]\n\
 \n\
 End of P\n\
 P2 (pid NNN)\n\
-\n\
-WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
-Explicit Allocations\n\
-\n\
 Other Measurements\n\
 \n\
 11 B ── z 0xNNN\n\
 \n\
 End of P2 (pid NNN)\n\
 P3\n\
-\n\
-WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
-Explicit Allocations\n\
-\n\
 Other Measurements\n\
 \n\
 -55 B ── p3 [-]\n\
 \n\
 End of P3\n\
 P4\n\
-\n\
-WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
-Explicit Allocations\n\
-\n\
 Other Measurements\n\
 \n\
 66 B ── p4 [+]\n\
 \n\
 End of P4\n\
 ";
 
   let frames = [
--- a/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul
+++ b/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul
@@ -130,20 +130,16 @@ 0.00 MB (100.0%) -- size\n\
 \n\
 0.00 MB (100.0%) -- swap\n\
 └──0.00 MB (100.0%) ── a\n\
 \n\
 250.00 MB ── heap-allocated\n\
 \n\
 End of Main Process (pid NNN)\n\
 Other-only process\n\
-\n\
-WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
-Explicit Allocations\n\
-\n\
 Other Measurements\n\
 \n\
 0.19 MB (100.0%) -- a\n\
 ├──0.10 MB (50.00%) ── b\n\
 └──0.10 MB (50.00%) ── c\n\
 \n\
 0.48 MB ── heap-allocated\n\
 \n\
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -131,23 +131,23 @@ interface nsIMemoryReporterCallback : ns
  *
  * An nsIMemoryReporter that reports a single measurement is sometimes called a
  * "uni-reporter".  One that reports multiple measurements is sometimes called
  * a "multi-reporter".
  *
  * aboutMemory.js is the most important consumer of memory reports.  It
  * places the following constraints on reports.
  *
- * - There must be an "explicit" tree.  It represents non-overlapping
- *   regions of memory that have been explicitly allocated with an
- *   OS-level allocation (e.g. mmap/VirtualAlloc/vm_allocate) or a
- *   heap-level allocation (e.g. malloc/calloc/operator new).  Reporters
- *   in this tree must have kind HEAP or NONHEAP, units BYTES.
+ * - All reports within a single sub-tree must have the same units.
  *
- * - All other reports are unconstrained.
+ * - There may be an "explicit" tree.  If present, it represents
+ *   non-overlapping regions of memory that have been explicitly allocated with
+ *   an OS-level allocation (e.g. mmap/VirtualAlloc/vm_allocate) or a
+ *   heap-level allocation (e.g. malloc/calloc/operator new).  Reporters in
+ *   this tree must have kind HEAP or NONHEAP, units BYTES.
  *
  * It is preferred, but not required, that report descriptions use complete
  * sentences (i.e. start with a capital letter and end with a period, or
  * similar).
  */
 [scriptable, uuid(0884cd0f-5829-4381-979b-0f53904030ed)]
 interface nsIMemoryReporter : nsISupports
 {