Platform/Memory Reporting: Difference between revisions

Jump to navigation Jump to search
Line 211: Line 211:
   foo->SizeOfExcludingThis()  // no
   foo->SizeOfExcludingThis()  // no


Sometimes the memory reporter is a stand-alone class, like the <tt>MyStringReporter</tt> example above. But often you'll have a singleton class that needs measuring, in which case it is usually better not to have a separate reporter object, but instead for the singleton class to implement <tt>nsIMemoryReporter</tt> and report its own memory consumption.  There are many examples of this in the code, such as <tt>nsCategoryManager</tt>.
Sometimes memory reporters are stand-alone objects, like the <tt>MyStringReporter</tt> example above. But often you'll have a singleton object that needs measuring, in which case it is usually better not to have a separate reporter object, but instead for the singleton object to implement <tt>nsIMemoryReporter</tt>, and thus measure and report its own memory consumption.  There are many such examples in the code, such as <tt>nsCategoryManager</tt>.


If you write a memory reporter, please get two people to review it: (a) someone who knows the data structures being measured, and (b) nnethercote, who can check for all the things covered by this document.  Thanks!
If you write a memory reporter, please get two people to review it: (a) someone who knows the data structures being measured, and (b) nnethercote, who can check for all the things covered by this document.  Thanks!
Confirmed users
1,345

edits

Navigation menu