Closed Bug 8161 Opened 25 years ago Closed 25 years ago

Leaking nsIServiceMgr in nsIAppShellComponentImpl

Categories

(SeaMonkey :: UI Design, defect, P1)

defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: scottputterman, Assigned: law)

Details

(Whiteboard: Fix is ready and approved)

I was looking into why none of my services are ever getting freed and one of the many reasons seems to be because mServiceMgr in nsIAppShellComponentImpl is never released. Therefore the global service manager can never get shutdown. Also, because this header file gets included in multiple libraries, there is actually a copy of mServiceMgr in each one. Since we currently have 3 components that include this file, there are 3 refcounts left over when we shutdown. I tried to figure this out but didn't have much luck.
OS: Windows NT → All
Priority: P3 → P1
Hardware: PC → All
Target Milestone: M8
Bill, any luck we could fix this for M7?
Status: NEW → ASSIGNED
I think I need to add a Release() call on mServiceMgr somewhere in the component shutdown code. I'll look at this later today.
Target Milestone: M8 → M7
I have a fix in hand so I'm changing this to M7. The change consisted of simply adding a call to mServiceMgr->Release() in nsAppShellComponentImpl::Shutdown().
Whiteboard: Fix is ready and approved
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
This fix was just checked in: Index: nsIAppShellComponentImpl.h =================================================================== RCS file: /cvsroot/mozilla/xpfe/components/public/nsIAppShellComponentImpl.h,v retrieving revision 1.6 diff -r1.6 nsIAppShellComponentImpl.h 154,155c154,159 < if ( mServiceMgr && Is_Service() ) { \ < rv = mServiceMgr->ReleaseService( progId, this ); \ --- > if ( mServiceMgr ) { \ > if ( Is_Service() ) { \ > rv = mServiceMgr->ReleaseService( progId, this ); \ > } \ > mServiceMgr->Release(); \ > mServiceMgr = 0; \
Status: RESOLVED → REOPENED
I tried this out and it still leaks the refcounts, so I'm reopening. Apparently, NSCanUnload( nsISupports* aServiceMgr ) gets called after ShutDown. In this function you call SetServiceManager which creates (and therefore AddRefs) another service manager if the value is currently NULL, which it is after you released it in ShutDown. So, this extra reference still exists. Is SetServiceManager necessary in NSCanUnload?
Resolution: FIXED → ---
Clearing Fixed resolution.
In case anyone's holding up M7 for this, I just wanted to point out that since there are other ref counting problems on nsServiceManager that aren't going to be fixed for M7, this bug fix will help, but it won't actually change anything.
Status: REOPENED → RESOLVED
Closed: 25 years ago25 years ago
Resolution: --- → FIXED
Doh! I've fixed this so it doesn't addref the service manager from NSCanUnload.
Status: RESOLVED → VERIFIED
It looks fixed now. Marking verified.
Product: Core → Mozilla Application Suite
You need to log in before you can comment on or make changes to this bug.