Bug 1266630 - Make fallible the orphan node table used during memory reporting. r=mccr8.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 22 Apr 2016 14:03:54 +1000
changeset 332316 e1b99e5251cb9ba6620599a2c1f7e54d00fc413c
parent 332315 1c638e1c121c51a803f3457e910cba1b021838b1
child 332317 c5d652fb84d1af80c93796af3c7cb96ae7999615
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1266630
milestone48.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 1266630 - Make fallible the orphan node table used during memory reporting. r=mccr8. This fixes some OOM crashes. MozReview-Commit-ID: LqWlpIzYTGM
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2736,18 +2736,22 @@ class OrphanReporter : public JS::Object
         if (node && !node->IsInUncomposedDoc() &&
             !(node->IsElement() && node->AsElement()->IsInNamespace(kNameSpaceID_XBL)))
         {
             // This is an orphan node.  If we haven't already handled the
             // sub-tree that this node belongs to, measure the sub-tree's size
             // and then record its root so we don't measure it again.
             nsCOMPtr<nsINode> orphanTree = node->SubtreeRoot();
             if (!mAlreadyMeasuredOrphanTrees.Contains(orphanTree)) {
-                n += SizeOfTreeIncludingThis(orphanTree);
-                mAlreadyMeasuredOrphanTrees.PutEntry(orphanTree);
+                // If PutEntry() fails we don't measure this tree, which could
+                // lead to under-measurement. But that's better than the
+                // alternatives, which are over-measurement or an OOM abort.
+                if (mAlreadyMeasuredOrphanTrees.PutEntry(orphanTree, fallible)) {
+                    n += SizeOfTreeIncludingThis(orphanTree);
+                }
             }
         }
         return n;
     }
 
   private:
     nsTHashtable <nsISupportsHashKey> mAlreadyMeasuredOrphanTrees;
 };