Bug 1344848 - Don't check for atom leaks unless we're checking for other leaks. r=erahm
MozReview-Commit-ID: H5x8cLv0YGk
--- 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