From 1d16bbcdf5ce97448957ab2d7a0aa48e90577d1c Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Sun, 6 Aug 2000 16:23:04 +0000 Subject: [PATCH] Fix crash on shutdown (or patch things up so they don't crash) by releasing memory pressure observers closer to the beginning of XPCOM shutdown. b=47791 r=waterson@netscape.com git-svn-id: svn://10.0.0.236/trunk@75682 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/base/nsMemoryImpl.cpp | 10 +++++++--- mozilla/xpcom/base/nsMemoryImpl.h | 1 + mozilla/xpcom/build/nsXPComInit.cpp | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mozilla/xpcom/base/nsMemoryImpl.cpp b/mozilla/xpcom/base/nsMemoryImpl.cpp index 63412a25856..14163d5f419 100644 --- a/mozilla/xpcom/base/nsMemoryImpl.cpp +++ b/mozilla/xpcom/base/nsMemoryImpl.cpp @@ -195,12 +195,16 @@ nsMemoryImpl::Startup() return Create(nsnull, NS_GET_IID(nsIMemory), (void**)&gMemory); } +nsresult +nsMemoryImpl::ReleaseObservers() +{ + // set mObservers to null to release observers + ((nsMemoryImpl*)gMemory)->mObservers = nsnull; +} + nsresult nsMemoryImpl::Shutdown() { - // set mObservers to null just to be conservative: - ((nsMemoryImpl*)gMemory)->mObservers = nsnull; - NS_RELEASE(gMemory); gMemory = nsnull; return NS_OK; diff --git a/mozilla/xpcom/base/nsMemoryImpl.h b/mozilla/xpcom/base/nsMemoryImpl.h index e1cb005c6fa..c2420d0ff00 100644 --- a/mozilla/xpcom/base/nsMemoryImpl.h +++ b/mozilla/xpcom/base/nsMemoryImpl.h @@ -40,6 +40,7 @@ public: // called from xpcom initialization/finalization: static nsresult Startup(); + static nsresult ReleaseObservers(); static nsresult Shutdown(); static NS_METHOD diff --git a/mozilla/xpcom/build/nsXPComInit.cpp b/mozilla/xpcom/build/nsXPComInit.cpp index 73a3d56f97e..3825ec644f1 100644 --- a/mozilla/xpcom/build/nsXPComInit.cpp +++ b/mozilla/xpcom/build/nsXPComInit.cpp @@ -611,6 +611,10 @@ nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr) // will cause servicemanager to become inaccessible. gShuttingDown = PR_TRUE; + // Release memory pressure observers now so that things get + // released earlier. + nsMemoryImpl::ReleaseObservers(); + // Release our own singletons... XPTI_FreeInterfaceInfoManager();