nsMemoryImpl::ReleaseObservers();
nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr){    nsrefcnt cnt;    // Notify observers of xpcom shutting down    nsresult rv = NS_OK;    {        // Block it so that the COMPtr will get deleted before we hit        // servicemanager shutdown        NS_WITH_SERVICE (nsIObserverService, observerService, NS_OBSERVERSERVICE_CONTRACTID, &rv);        if (NS_SUCCEEDED(rv))        {            nsIServiceManager *mgr;    // NO COMPtr as we dont release the service manager            rv = nsServiceManager::GetGlobalServiceManager(&mgr);            if (NS_SUCCEEDED(rv))            {                nsAutoString topic;                topic.AssignWithConversion(NS_XPCOM_SHUTDOWN_OBSERVER_ID);                (void) observerService->Notify(mgr, topic.GetUnicode(), nsnull);            }        }    }    // XPCOM is officially in shutdown mode NOW    // Set this only after the observers have been notified as this    // will cause servicemanager to become inaccessible.    gShuttingDown = PR_TRUE;    // Release memory pressure observers now so that things get    // released earlier.    nsMemoryImpl::ReleaseObservers();    // We may have AddRef'd for the caller of NS_InitXPCOM, so release it    // here again:    NS_IF_RELEASE(servMgr);    // Shutdown global servicemanager    nsServiceManager::ShutdownGlobalServiceManager(NULL);#ifndef XPCOM_STANDALONE    // Release the global case converter    NS_IF_RELEASE(gCaseConv);#endif /* XPCOM_STANDALONE */        // Release the directory service    NS_IF_RELEASE(gDirectoryService);    // Shutdown xpcom. This will release all loaders and cause others holding    // a refcount to the component manager to release it.    rv = (nsComponentManagerImpl::gComponentManager)->Shutdown();    NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed.");    // Release our own singletons    // Do this _after_ shutting down the component manager, because the    // JS component loader will use XPConnect to call nsIModule::canUnload,    // and that will spin up the InterfaceInfoManager again -- bad mojo    XPTI_FreeInterfaceInfoManager();    // Finally, release the component manager last because it unloads the    // libraries:    NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt);    NS_WARN_IF_FALSE(cnt == 0, "Component Manager being held past XPCOM shutdown.");#ifdef DEBUG    extern void _FreeAutoLockStatics();    _FreeAutoLockStatics();#endif    nsThread::Shutdown();    nsMemoryImpl::Shutdown();    NS_PurgeAtomTable();#if (defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING))    nsTraceRefcnt::DumpStatistics();    nsTraceRefcnt::ResetStatistics();#endif#ifdef GC_LEAK_DETECTOR    // Shutdown the Leak detector.    NS_ShutdownLeakDetector();#endif    return NS_OK;}