Bug 1383982 - Introduce a general mechanism for measuring memory usage of graph-like structures. r=erahm.

All the SizeOf{In,Ex}cludingThis() functions take a MallocSizeOf function
which measures memory blocks. This patch introduces a new type, SizeOfState,
which includes a MallocSizeOf function *and* a table of already-measured
pointers, called SeenPtrs. This gives us a general mechanism to measure
graph-like data structures, by recording which nodes have already been
measured. (This approach is used in a number of existing reporters, but not in
a uniform fashion.)

The patch also converts the window memory reporting to use SizeOfState in a lot
of places, all the way through to the measurement of Elements. This is a
precursor for bug 1383977 which will measure Stylo elements, which involve
Arcs.

The patch also converts the existing mAlreadyMeasuredOrphanTrees table in the
OrphanReporter to use the new mechanism.
This commit is contained in:
Nicholas Nethercote
2017-07-28 15:03:44 +10:00
parent aadd9daf28
commit d50718f5d2
33 changed files with 203 additions and 102 deletions

View File

@@ -509,10 +509,10 @@ HTMLLinkElement::IntrinsicState() const
}
size_t
HTMLLinkElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
HTMLLinkElement::SizeOfExcludingThis(mozilla::SizeOfState& aState) const
{
return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
Link::SizeOfExcludingThis(aMallocSizeOf);
return nsGenericHTMLElement::SizeOfExcludingThis(aState) +
Link::SizeOfExcludingThis(aState);
}
JSObject*