Bug 822700 - When DMD is disabled its SizeOf() function shouldn't try to measure non-existent structures. r+a=jlebar
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 18 Dec 2012 15:14:31 -0800
changeset 123058 8e0337f05bbf6fcea2bebc956203f1001b66d25c
parent 123057 22b738bec2fd12dcca952b48e60a5536639597d1
child 123059 7c2364d6f803d0ed663a1ffd8d655d0668732c6b
push id273
push userlsblakk@mozilla.com
push dateThu, 14 Feb 2013 23:19:38 +0000
treeherdermozilla-release@c5e807a3f8b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs822700
milestone19.0a2
Bug 822700 - When DMD is disabled its SizeOf() function shouldn't try to measure non-existent structures. r+a=jlebar
memory/replace/dmd/DMD.cpp
memory/replace/dmd/DMD.h
--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -1968,16 +1968,21 @@ PrintSortedBlockAndFrameGroups(const Wri
 
 // Note that, unlike most SizeOf* functions, this function does not take a
 // |nsMallocSizeOfFun| argument.  That's because those arguments are primarily
 // to aid DMD track heap blocks... but DMD deliberately doesn't track heap
 // blocks it allocated for itself!
 MOZ_EXPORT void
 SizeOf(Sizes* aSizes)
 {
+  if (!gIsDMDRunning) {
+    aSizes->Clear();
+    return;
+  }
+
   aSizes->mStackTraces = 0;
   for (StackTraceTable::Range r = gStackTraceTable->all();
        !r.empty();
        r.popFront()) {
     StackTrace* const& st = r.front();
     aSizes->mStackTraces += MallocSizeOf(st);
   }
 
--- a/memory/replace/dmd/DMD.h
+++ b/memory/replace/dmd/DMD.h
@@ -52,17 +52,18 @@ FpWrite(void* aFp, const char* aFmt, va_
 
 struct Sizes
 {
   size_t mStackTraces;
   size_t mStackTraceTable;
   size_t mLiveBlockTable;
   size_t mDoubleReportTable;
 
-  Sizes() { memset(this, 0, sizeof(Sizes)); }
+  Sizes() { Clear(); }
+  void Clear() { memset(this, 0, sizeof(Sizes)); }
 };
 
 // Gets the size of various data structures.  Used to implement a memory
 // reporter for DMD.
 MOZ_EXPORT void
 SizeOf(Sizes* aSizes);
 
 } // namespace mozilla