Bug 752952 - account for nsIDocument's property tables in about:memory; r=njn,f=smaug

This commit is contained in:
Nathan Froyd 2012-06-15 00:10:08 -04:00
parent 6851f5438e
commit 630362934d
5 changed files with 43 additions and 0 deletions

View File

@ -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!

View File

@ -52,6 +52,8 @@ public:
return mName == aPropertyName;
}
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
nsCOMPtr<nsIAtom> 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,

View File

@ -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;

View File

@ -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.");

View File

@ -39,6 +39,7 @@ public:
size_t mLayoutStyleSets;
size_t mLayoutTextRuns;
size_t mLayoutPresContext;
size_t mPropertyTables;
};
/**