Bug 1344848 - Don't check for atom leaks unless we're checking for other leaks. r=erahm
authorAndrew McCreight <continuation@gmail.com>
Mon, 06 Mar 2017 11:50:30 -0800
changeset 346131 7818d19d769d177ed68596d02eb0a10b4d48b7cc
parent 346130 07345c5aa0734f345f4166e5b24702ad8da10c1f
child 346132 f1327d3dcdcb3bcaa80a0536eebb1c74c8429995
push id38426
push useramccreight@mozilla.com
push dateTue, 07 Mar 2017 02:11:49 +0000
treeherderautoland@7818d19d769d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1344848
milestone54.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 1344848 - Don't check for atom leaks unless we're checking for other leaks. r=erahm MozReview-Commit-ID: H5x8cLv0YGk
xpcom/ds/nsAtomTable.cpp
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -384,31 +384,36 @@ DynamicAtom::GCAtomTableLocked(const Mut
       continue;
     }
 
     auto atom = static_cast<DynamicAtom*>(entry->mAtom);
     if (atom->mRefCnt == 0) {
       i.Remove();
       delete atom;
       ++removedCount;
-    } else if (aKind == GCKind::Shutdown) {
-      // We only perform these kind of GCs in leak-checking builds.  If
-      // something is anomalous, then we'll report an error here, and crash
-      // later on in this function.
+    }
+#ifdef NS_FREE_PERMANENT_DATA
+    else if (aKind == GCKind::Shutdown && PR_GetEnv("XPCOM_MEM_BLOAT_LOG")) {
+      // Only report leaking atoms in leak-checking builds in a run
+      // where we are checking for leaks, during shutdown. If
+      // something is anomalous, then we'll assert later in this
+      // function.
       nsAutoCString name;
       atom->ToUTF8String(name);
       if (nonZeroRefcountAtomsCount == 0) {
         nonZeroRefcountAtoms = name;
       } else if (nonZeroRefcountAtomsCount < 20) {
         nonZeroRefcountAtoms += NS_LITERAL_CSTRING(",") + name;
       } else if (nonZeroRefcountAtomsCount == 20) {
         nonZeroRefcountAtoms += NS_LITERAL_CSTRING(",...");
       }
       nonZeroRefcountAtomsCount++;
     }
+#endif
+
   }
   if (nonZeroRefcountAtomsCount) {
     nsPrintfCString msg("%d dynamic atom(s) with non-zero refcount: %s",
                         nonZeroRefcountAtomsCount, nonZeroRefcountAtoms.get());
     NS_ASSERTION(nonZeroRefcountAtomsCount == 0, msg.get());
   }
 
   // During the course of this function, the atom table is locked. This means