diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index fa8de27f0f5..9dc101a702f 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -9608,6 +9608,14 @@ nsIDocument::DocSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const &aWindowSizes->mLayoutPresContext); } + aWindowSizes->mPropertyTables += + mPropertyTable.SizeOfExcludingThis(aWindowSizes->mMallocSizeOf); + for (PRUint32 i = 0, count = mExtraPropertyTables.Length(); + i < count; ++i) { + aWindowSizes->mPropertyTables += + mExtraPropertyTables[i]->SizeOfExcludingThis(aWindowSizes->mMallocSizeOf); + } + // Measurement of the following members may be added later if DMD finds it // is worthwhile: // - many! diff --git a/content/base/src/nsPropertyTable.cpp b/content/base/src/nsPropertyTable.cpp index cb0adeeef4d..98ceb81d465 100644 --- a/content/base/src/nsPropertyTable.cpp +++ b/content/base/src/nsPropertyTable.cpp @@ -52,6 +52,8 @@ public: return mName == aPropertyName; } + size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + nsCOMPtr mName; // property name PLDHashTable mObjectValueMap; // map of object/value pairs NSPropertyDtorFunc mDtorFunc; // property specific value dtor function @@ -337,6 +339,26 @@ nsPropertyTable::PropertyList::DeletePropertyFor(nsPropertyOwner aObject) return true; } +size_t +nsPropertyTable::PropertyList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +{ + size_t n = aMallocSizeOf(this); + n += PL_DHashTableSizeOfExcludingThis(&mObjectValueMap, NULL, aMallocSizeOf); + return n; +} + +size_t +nsPropertyTable::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +{ + size_t n = 0; + + for (PropertyList *prop = mPropertyList; prop; prop = prop->mNext) { + n += prop->SizeOfIncludingThis(aMallocSizeOf); + } + + return n; +} + /* static */ void nsPropertyTable::SupportsDtorFunc(void *aObject, nsIAtom *aPropertyName, diff --git a/content/base/src/nsPropertyTable.h b/content/base/src/nsPropertyTable.h index b66e511ff3e..4a35b9a6286 100644 --- a/content/base/src/nsPropertyTable.h +++ b/content/base/src/nsPropertyTable.h @@ -177,6 +177,8 @@ class nsPropertyTable class PropertyList; + size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + private: NS_HIDDEN_(void) DestroyPropertyList(); NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom *aPropertyName) const; diff --git a/dom/base/nsWindowMemoryReporter.cpp b/dom/base/nsWindowMemoryReporter.cpp index ecd31cb603e..8f80f4563e8 100644 --- a/dom/base/nsWindowMemoryReporter.cpp +++ b/dom/base/nsWindowMemoryReporter.cpp @@ -177,6 +177,11 @@ CollectWindowReports(nsGlobalWindow *aWindow, "Memory used by the comment nodes in a window's DOM."); aWindowTotalSizes->mDOMCommentNodes += windowSizes.mDOMCommentNodes; + REPORT("/property-tables", + windowSizes.mPropertyTables, + "Memory used for the property tables within a window."); + aWindowTotalSizes->mPropertyTables += windowSizes.mPropertyTables; + REPORT("/style-sheets", windowSizes.mStyleSheets, "Memory used by style sheets within a window."); aWindowTotalSizes->mStyleSheets += windowSizes.mStyleSheets; @@ -328,6 +333,11 @@ nsWindowMemoryReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb, "Memory used for DOM comment nodes within windows. " "This is the sum of all windows' 'dom/comment-nodes' numbers."); + REPORT("window-objects/property-tables", + windowTotalSizes.mPropertyTables, + "Memory used for property tables within windows. " + "This is the sum of all windows' 'property-tables' numbers."); + REPORT("window-objects/style-sheets", windowTotalSizes.mStyleSheets, "Memory used for style sheets within windows. " "This is the sum of all windows' 'style-sheets' numbers."); diff --git a/dom/base/nsWindowMemoryReporter.h b/dom/base/nsWindowMemoryReporter.h index a953204d7f5..5e155dc6651 100644 --- a/dom/base/nsWindowMemoryReporter.h +++ b/dom/base/nsWindowMemoryReporter.h @@ -39,6 +39,7 @@ public: size_t mLayoutStyleSets; size_t mLayoutTextRuns; size_t mLayoutPresContext; + size_t mPropertyTables; }; /**