mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 04:58:00 +00:00
Bug 1291970 (part 2) - Tweak nsCategoryManager memory reporter handling. r=erahm.
This patch adds an assertion that makes sure that the nsCategoryManager is destroyed after the nsMemoryReporterManager, because bad things would happen otherwise. Also, nsCategoryManager uses manual memory management (it's AddRef/Release are hardwired to always return 2 and 1 respectively) so it doesn't matter if we register it as a strong or weak memory reporter. But it's more common to use RegisterWeakMemoryReporter when the argument is |this|, so this patch does that. --HG-- extra : rebase_source : 4ca33404d4c6f2b271e1ad008ea1a9a79f3ef666
This commit is contained in:
parent
9d5a878581
commit
736c7b1407
@ -393,6 +393,12 @@ nsCategoryManager::GetSingleton()
|
||||
/* static */ void
|
||||
nsCategoryManager::Destroy()
|
||||
{
|
||||
// The nsMemoryReporterManager gets destroyed before the nsCategoryManager,
|
||||
// so we don't need to unregister the nsCategoryManager as a memory reporter.
|
||||
// In debug builds we assert that unregistering fails, as a way (imperfect
|
||||
// but better than nothing) of testing the "destroyed before" part.
|
||||
MOZ_ASSERT(NS_FAILED(UnregisterWeakMemoryReporter(gCategoryManager)));
|
||||
|
||||
delete gCategoryManager;
|
||||
gCategoryManager = nullptr;
|
||||
}
|
||||
@ -418,7 +424,7 @@ nsCategoryManager::nsCategoryManager()
|
||||
void
|
||||
nsCategoryManager::InitMemoryReporter()
|
||||
{
|
||||
RegisterStrongMemoryReporter(this);
|
||||
RegisterWeakMemoryReporter(this);
|
||||
}
|
||||
|
||||
nsCategoryManager::~nsCategoryManager()
|
||||
|
Loading…
x
Reference in New Issue
Block a user