Bug 826553 - Add a memory reporter for the event listener manager's hash table. r=bz.

--HG--
extra : rebase_source : 72584fbf0b80c1e8d5451486ca2c46efebc93b44
This commit is contained in:
Nicholas Nethercote 2013-01-03 21:26:56 -08:00
parent c8deef991c
commit 3ee5b531ad
2 changed files with 28 additions and 1 deletions

View File

@ -247,6 +247,25 @@ static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
static PLDHashTable sEventListenerManagersHash;
static nsCOMPtr<nsIMemoryReporter> sEventListenerManagersHashReporter;
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(EventListenerManagersHashMallocSizeOf)
static int64_t GetEventListenerManagersHash()
{
// We don't measure the |nsEventListenerManager| objects pointed to by the
// entries because those references are non-owning.
return PL_DHashTableSizeOfExcludingThis(&sEventListenerManagersHash,
nullptr,
EventListenerManagersHashMallocSizeOf);
}
NS_MEMORY_REPORTER_IMPLEMENT(EventListenerManagersHash,
"explicit/dom/event-listener-managers-hash",
KIND_HEAP,
UNITS_BYTES,
GetEventListenerManagersHash,
"Memory used by the event listener manager's hash table.")
class EventListenerManagerMapEntry : public PLDHashEntryHdr
{
@ -383,6 +402,10 @@ nsContentUtils::Init()
return NS_ERROR_OUT_OF_MEMORY;
}
sEventListenerManagersHashReporter =
new NS_MEMORY_REPORTER_NAME(EventListenerManagersHash);
(void)::NS_RegisterMemoryReporter(sEventListenerManagersHashReporter);
}
sBlockedScriptRunners = new nsTArray< nsCOMPtr<nsIRunnable> >;
@ -1464,6 +1487,9 @@ nsContentUtils::Shutdown()
if (sEventListenerManagersHash.entryCount == 0) {
PL_DHashTableFinish(&sEventListenerManagersHash);
sEventListenerManagersHash.ops = nullptr;
(void)::NS_UnregisterMemoryReporter(sEventListenerManagersHashReporter);
sEventListenerManagersHashReporter = nullptr;
}
}

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 et sw=4 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */