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

This commit is contained in:
dbaron%fas.harvard.edu 2000-08-06 16:23:04 +00:00
parent ec2dd3adc2
commit 710b05e789
3 changed files with 12 additions and 3 deletions

View File

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

View File

@ -40,6 +40,7 @@ public:
// called from xpcom initialization/finalization:
static nsresult Startup();
static nsresult ReleaseObservers();
static nsresult Shutdown();
static NS_METHOD

View File

@ -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();