Bug 624870: Free nsFactoryEntrys on XPCOM shutdown and factory unregistration. r=bsmedberg
☠☠ backed out by ed9ed84a7117 ☠ ☠
authorKyle Huey <khuey@kylehuey.com>
Wed, 13 Apr 2011 19:41:34 -0700
changeset 68097 aa200a803e07fe55056ee048b058d3e9bad548a2
parent 68096 347c9f93d23b3ed4290cb7a175d4df2cac8934cf
child 68098 ed9ed84a7117b62e52a77e0fd7914f1dd43e4ad1
push id19507
push userkhuey@kylehuey.com
push dateThu, 14 Apr 2011 02:48:21 +0000
treeherdermozilla-central@aa200a803e07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs624870
milestone6.0a1
first release with
nightly linux32
aa200a803e07 / 6.0a1 / 20110414030535 / files
nightly linux64
aa200a803e07 / 6.0a1 / 20110414030535 / files
nightly mac
aa200a803e07 / 6.0a1 / 20110414030535 / files
nightly win32
aa200a803e07 / 6.0a1 / 20110414030535 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 624870: Free nsFactoryEntrys on XPCOM shutdown and factory unregistration. r=bsmedberg
xpcom/components/nsComponentManager.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -1319,16 +1319,17 @@ nsComponentManagerImpl::CreateInstanceBy
 
 static PLDHashOperator
 FreeFactoryEntries(const nsID& aCID,
                    nsFactoryEntry* aEntry,
                    void* arg)
 {
     aEntry->mFactory = NULL;
     aEntry->mServiceObject = NULL;
+    delete aEntry;
     return PL_DHASH_NEXT;
 }
 
 nsresult
 nsComponentManagerImpl::FreeServices()
 {
     NS_ASSERTION(gXPCOMShuttingDown, "Must be shutting down in order to free all services");
 
@@ -1792,16 +1793,17 @@ nsComponentManagerImpl::UnregisterFactor
 
         mFactories.Remove(aClass);
 
         // This might leave a stale contractid -> factory mapping in
         // place, so null out the factory entry (see
         // nsFactoryEntry::GetFactory)
         f->mFactory.swap(dyingFactory);
         f->mServiceObject.swap(dyingServiceObject);
+        delete f;
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsComponentManagerImpl::AutoRegister(nsIFile* aLocation)
 {
@@ -1936,37 +1938,40 @@ nsComponentManagerImpl::ContractIDToCID(
 // nsFactoryEntry
 ////////////////////////////////////////////////////////////////////////////////
 
 nsFactoryEntry::nsFactoryEntry(const mozilla::Module::CIDEntry* entry,
                                nsComponentManagerImpl::KnownModule* module)
     : mCIDEntry(entry)
     , mModule(module)
 {
+    MOZ_COUNT_CTOR(nsFactoryEntry);
 }
 
 nsFactoryEntry::nsFactoryEntry(const nsCID& aCID, nsIFactory* factory)
     : mCIDEntry(NULL)
     , mModule(NULL)
     , mFactory(factory)
 {
+    MOZ_COUNT_CTOR(nsFactoryEntry);
     mozilla::Module::CIDEntry* e = new mozilla::Module::CIDEntry();
     nsCID* cid = new nsCID;
     *cid = aCID;
     e->cid = cid;
     mCIDEntry = e;
 }        
 
 nsFactoryEntry::~nsFactoryEntry()
 {
     // If this was a RegisterFactory entry, we own the CIDEntry/CID
     if (!mModule) {
         delete mCIDEntry->cid;
         delete mCIDEntry;
     }
+    MOZ_COUNT_DTOR(nsFactoryEntry);
 }
 
 already_AddRefed<nsIFactory>
 nsFactoryEntry::GetFactory()
 {
     if (!mFactory) {
         // RegisterFactory then UnregisterFactory can leave an entry in mContractIDs
         // pointing to an unusable nsFactoryEntry.