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
Родитель c0e76d61c8
Коммит a77d4b0fcc
2 изменённых файлов: 28 добавлений и 1 удалений

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

@ -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;
}
}

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

@ -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/. */