Platform/Memory Reporting: Difference between revisions

Jump to navigation Jump to search
Line 169: Line 169:


Sometimes it's difficult and/or not worth measuring every member of an object of in a <tt>Foo::SizeOfExcludingThis</tt> method.  This is ok, but it's worth adding a comment explaining this to the method.
Sometimes it's difficult and/or not worth measuring every member of an object of in a <tt>Foo::SizeOfExcludingThis</tt> method.  This is ok, but it's worth adding a comment explaining this to the method.
Occasionally you do want to compute sizes analytically instead of using <tt>moz_malloc_size_of</tt>.  In that case, use <tt>ComputedSizeOf</tt> as the prefix for the function name.


It's important that no memory is measured twice;  this can lead to very strange results in about:memory.  Avoiding double measurement is easy in tree-like structures.  In graph-like structures (where an object might be pointed to by more than one other object) it gets more difficult, and might even require some way to mark objects that have been counted (and then a way to unmark them once the measurement is complete).
It's important that no memory is measured twice;  this can lead to very strange results in about:memory.  Avoiding double measurement is easy in tree-like structures.  In graph-like structures (where an object might be pointed to by more than one other object) it gets more difficult, and might even require some way to mark objects that have been counted (and then a way to unmark them once the measurement is complete).
Confirmed users
1,345

edits

Navigation menu