Bug 1474636 - Report memory used by nsMemoryReporterManager. r=njn

This adds reporting of nsMemoryReporterManager's internals. Currently we just
report the weak and strong ref hashtables which have shown up in DMD reports.

The new entry is '/explicit/memory-reporter-manager'.

--HG--
extra : rebase_source : ab785a96a0dd52a4e09718bea015363cdf2c9c8a
extra : source : 86ba30c70a27ab73f096fe88d2005aad8470ee05
This commit is contained in:
Eric Rahm 2018-07-10 15:38:52 -07:00
Родитель a10348a5ca
Коммит 599ee96a71
2 изменённых файлов: 25 добавлений и 2 удалений

Просмотреть файл

@ -1521,7 +1521,7 @@ NS_IMPL_ISUPPORTS(DMDReporter, nsIMemoryReporter)
** nsMemoryReporterManager implementation ** nsMemoryReporterManager implementation
**/ **/
NS_IMPL_ISUPPORTS(nsMemoryReporterManager, nsIMemoryReporterManager) NS_IMPL_ISUPPORTS(nsMemoryReporterManager, nsIMemoryReporterManager, nsIMemoryReporter)
NS_IMETHODIMP NS_IMETHODIMP
nsMemoryReporterManager::Init() nsMemoryReporterManager::Init()
@ -1614,6 +1614,9 @@ nsMemoryReporterManager::Init()
nsMemoryInfoDumper::Initialize(); nsMemoryInfoDumper::Initialize();
#endif #endif
// Report our own memory usage as well.
RegisterWeakReporter(this);
return NS_OK; return NS_OK;
} }
@ -1641,6 +1644,22 @@ nsMemoryReporterManager::~nsMemoryReporterManager()
NS_ASSERTION(!mSavedWeakReporters, "failed to restore weak reporters"); NS_ASSERTION(!mSavedWeakReporters, "failed to restore weak reporters");
} }
NS_IMETHODIMP
nsMemoryReporterManager::CollectReports(nsIHandleReportCallback* aHandleReport,
nsISupports* aData, bool aAnonymize)
{
size_t n = MallocSizeOf(this);
n += mStrongReporters->ShallowSizeOfIncludingThis(MallocSizeOf);
n += mWeakReporters->ShallowSizeOfIncludingThis(MallocSizeOf);
MOZ_COLLECT_REPORT(
"explicit/memory-reporter-manager", KIND_HEAP, UNITS_BYTES,
n,
"Memory used by the memory reporter infrastructure.");
return NS_OK;
}
#ifdef DEBUG_CHILD_PROCESS_MEMORY_REPORTING #ifdef DEBUG_CHILD_PROCESS_MEMORY_REPORTING
#define MEMORY_REPORTING_LOG(format, ...) \ #define MEMORY_REPORTING_LOG(format, ...) \
printf_stderr("++++ MEMORY REPORTING: " format, ##__VA_ARGS__); printf_stderr("++++ MEMORY REPORTING: " format, ##__VA_ARGS__);

Просмотреть файл

@ -25,13 +25,17 @@ class MemoryReport;
class nsITimer; class nsITimer;
class nsMemoryReporterManager final : public nsIMemoryReporterManager class nsMemoryReporterManager final : public nsIMemoryReporterManager,
public nsIMemoryReporter
{ {
virtual ~nsMemoryReporterManager(); virtual ~nsMemoryReporterManager();
public: public:
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIMEMORYREPORTERMANAGER NS_DECL_NSIMEMORYREPORTERMANAGER
NS_DECL_NSIMEMORYREPORTER
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
nsMemoryReporterManager(); nsMemoryReporterManager();