diff --git a/xpcom/components/nsCategoryManager.cpp b/xpcom/components/nsCategoryManager.cpp index 4cf42f8afae1..2f205ebb65e8 100644 --- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -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()