зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
c0e76d61c8
Коммит
a77d4b0fcc
|
@ -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/. */
|
||||
|
|
Загрузка…
Ссылка в новой задаче