From 946af7a12ef058475b951d78eaccc22aa514d05d Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 10 Sep 2013 08:56:36 -0700 Subject: [PATCH] Bug 913881, part 6 - Measure weak map representations in the cycle collector graph. r=njn Contrary to the comment here, I'm pretty sure this needs to be measured. mWeakMaps is an array of little structs. Of course, in practice I doubt this amounts to anything. --- xpcom/base/nsCycleCollector.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 66c3810ec246..9d89f6553ce4 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -616,12 +616,14 @@ struct GCGraph } void SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, - size_t *aNodesSize, size_t *aEdgesSize) const { + size_t *aNodesSize, size_t *aEdgesSize, + size_t *aWeakMapsSize) const { *aNodesSize = mNodes.SizeOfExcludingThis(aMallocSizeOf); *aEdgesSize = mEdges.SizeOfExcludingThis(aMallocSizeOf); - // These fields are deliberately not measured: - // - mWeakMaps entries, because the pointers are non-owning + // We don't measure what the WeakMappings point to, because the + // pointers are non-owning. + *aWeakMapsSize = mWeakMaps.SizeOfExcludingThis(aMallocSizeOf); } }; @@ -976,6 +978,7 @@ public: size_t *aObjectSize, size_t *aGraphNodesSize, size_t *aGraphEdgesSize, + size_t *aWeakMapsSize, size_t *aWhiteNodeSize, size_t *aPurpleBufferSize) const; @@ -2405,11 +2408,13 @@ class CycleCollectorMultiReporter MOZ_FINAL : public nsIMemoryMultiReporter NS_IMETHOD CollectReports(nsIMemoryMultiReporterCallback* aCb, nsISupports* aClosure) { - size_t objectSize, graphNodesSize, graphEdgesSize, whiteNodesSize, - purpleBufferSize; + size_t objectSize, graphNodesSize, graphEdgesSize, weakMapsSize, + whiteNodesSize, purpleBufferSize; mCollector->SizeOfIncludingThis(MallocSizeOf, - &objectSize, &graphNodesSize, - &graphEdgesSize, &whiteNodesSize, + &objectSize, + &graphNodesSize, &graphEdgesSize, + &weakMapsSize, + &whiteNodesSize, &purpleBufferSize); #define REPORT(_path, _amount, _desc) \ @@ -2436,6 +2441,11 @@ class CycleCollectorMultiReporter MOZ_FINAL : public nsIMemoryMultiReporter "Memory used for the edges of the cycle collector's graph. " "This should be zero when the collector is idle."); + REPORT("explicit/cycle-collector/weak-maps", weakMapsSize, + "Memory used for the representation of weak maps in the " + "cycle collector's graph. " + "This should be zero when the collector is idle."); + REPORT("explicit/cycle-collector/white-nodes", whiteNodesSize, "Memory used for the cycle collector's white nodes array. " "This should be zero when the collector is idle."); @@ -2817,12 +2827,14 @@ nsCycleCollector::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, size_t *aObjectSize, size_t *aGraphNodesSize, size_t *aGraphEdgesSize, + size_t *aWeakMapsSize, size_t *aWhiteNodeSize, size_t *aPurpleBufferSize) const { *aObjectSize = aMallocSizeOf(this); - mGraph.SizeOfExcludingThis(aMallocSizeOf, aGraphNodesSize, aGraphEdgesSize); + mGraph.SizeOfExcludingThis(aMallocSizeOf, aGraphNodesSize, aGraphEdgesSize, + aWeakMapsSize); // No need to measure what the entries point to; the pointers are // non-owning.