Confirmed users
1,345
edits
Nnethercote (talk | contribs) |
Nnethercote (talk | contribs) |
||
| Line 87: | Line 87: | ||
class MyStringReporter MOZ_FINAL : public MemoryUniReporter | class MyStringReporter MOZ_FINAL : public MemoryUniReporter | ||
{ | { | ||
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf) | |||
public: | public: | ||
NS_DECL_ISUPPORTS | |||
NS_IMETHOD | |||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData) | |||
{ | { | ||
// BTW: If gMyString wasn't a pointer, you'd use | // BTW: If gMyString wasn't a pointer, you'd use | ||
// |gMyString.SizeOfExcludingThis(MallocSizeOf)| instead. | // |gMyString.SizeOfExcludingThis(MallocSizeOf)| instead. | ||
return gMyString->SizeOfIncludingThis(MallocSizeOf); | return MOZ_COLLECT_REPORT( | ||
"explicit/mystring", KIND_HEAP, UNITS_BYTES, | |||
gMyString->SizeOfIncludingThis(MallocSizeOf), | |||
"Memory used for MyString."); | |||
} | } | ||
}; | }; | ||
NS_IMPL_ISUPPORTS1(MyStringReporter, nsIMemoryReporter) | |||
Note that <tt>MOZ_DEFINE_MALLOC_SIZE_OF</tt> defines a function of type <tt>nsMallocSizeOfFun</tt> that is specific to this memory reporter (and will be identified as such in DMD's output). | |||
=== An Example Involving Inheritance === | === An Example Involving Inheritance === | ||