Closed Bug 347710 Opened 18 years ago Closed 18 years ago

nsDirPrefs leaks a DirPrefObserver on shutdown because we only release it on "profile-do-change"

Categories

(MailNews Core :: Address Book, defect)

1.8 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ispiked, Assigned: ispiked)

Details

(Keywords: fixed1.8.1, memory-leak)

Attachments

(1 file, 1 obsolete file)

Found using trace refcount logging.

nsDirPrefs AddRef's prefObserver here and then Releases it in its DIR_Shutdown method. http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/mailnews/addrbook/src/nsDirPrefs.cpp&rev=1.116&mark=249,271#247

This is all fine and good except DIR_Shutdown is only called from its observer (?) on "profile-do-change". http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/mailnews/addrbook/src/nsDirectoryDataSource.cpp&rev=1.74&mark=114,106#102

I'm guessing this is left over from the old days when you could switch profiles in place or something, but I'm not sure. 

Maybe we need to kill the "profile-do-change" topic and just move the DIR_Shutdown call to the "xpcom-shutdown" topic observer?
Attached patch patch? (obsolete) — Splinter Review
Assignee: nobody → ispiked
(In reply to comment #0)
> This is all fine and good except DIR_Shutdown is only called from its observer
> (?) on "profile-do-change".

> I'm guessing this is left over from the old days when you could switch profiles
> in place or something, but I'm not sure. 

You still can change profiles on SeaMonkey can't you? At least at the moment on trunk and on 1.8 branch.

Would NS_XPCOM_SHUTDOWN_OBSERVER_ID still be observed in the case of a profile change?
Maybe it would be better to use profile-before-change?
Can someone with a SeaMonkey build answer Mark's question in comment 2?
(In reply to comment #2)
>You still can change profiles on SeaMonkey can't you? At least at the moment on
>trunk and on 1.8 branch.
You'll always be able to change them on branch, but on Trunk we'll be stuffed by toolkit as usual.

>Would NS_XPCOM_SHUTDOWN_OBSERVER_ID still be observed in the case of a profile
>change?
No.
So couldn't we just call both DIR_Shutdown and Cleanup if we're shutting down, and only call DIR_Shutdown if we're switching profiles?
(In reply to comment #6)
> So couldn't we just call both DIR_Shutdown and Cleanup if we're shutting down,
> and only call DIR_Shutdown if we're switching profiles?

That would sound reasonable.
We need to call this when we shutdown, too, not just when we're doing a profile switch (it even says so in the comment after the function declaration!).
Attachment #232502 - Attachment is obsolete: true
Attachment #236571 - Flags: superreview?(bienvenu)
Attachment #236571 - Flags: review?(bienvenu)
Comment on attachment 236571 [details] [diff] [review]
Call DIR_ShutDown when we're shutting down, too

thx, Adam.
Attachment #236571 - Flags: superreview?(bienvenu)
Attachment #236571 - Flags: superreview+
Attachment #236571 - Flags: review?(bienvenu)
Attachment #236571 - Flags: review+
Whiteboard: [checkin needed]
I've just checked this in:

Checking in mailnews/addrbook/src/nsDirectoryDataSource.cpp;
/cvsroot/mozilla/mailnews/addrbook/src/nsDirectoryDataSource.cpp,v  <--  nsDirectoryDataSource.cpp
new revision: 1.76; previous revision: 1.75
done
Whiteboard: [checkin needed]
Comment on attachment 236571 [details] [diff] [review]
Call DIR_ShutDown when we're shutting down, too

Requesting branch approval for this leak fix when opening the address book window.
Attachment #236571 - Flags: approval-thunderbird2?
Comment on attachment 236571 [details] [diff] [review]
Call DIR_ShutDown when we're shutting down, too

If Mark doesn't have any objections, this looks good for the 1.8.1 branch for seamonkey and thunderbird.
Attachment #236571 - Flags: approval-thunderbird2? → approval-thunderbird2+
Whiteboard: [checkin needed (1.8 branch)]
(In reply to comment #12)
> (From update of attachment 236571 [details] [diff] [review] [edit])
> If Mark doesn't have any objections, this looks good for the 1.8.1 branch for
> seamonkey and thunderbird.
> 
That's fine by me. I'll check it in tomorrow unless someone does it before me or the tree closes.
Checked in on branch as well.
Checking in mailnews/addrbook/src/nsDirectoryDataSource.cpp;
/cvsroot/mozilla/mailnews/addrbook/src/nsDirectoryDataSource.cpp,v  <--  nsDirectoryDataSource.cpp
new revision: 1.67.2.2; previous revision: 1.67.2.1

I assume this is fixed now - so marking fixed. Apologies in advance if I am wrong.

Thanks for the patch Adam.
Status: NEW → RESOLVED
Closed: 18 years ago
Keywords: fixed1.8.1
Resolution: --- → FIXED
Whiteboard: [checkin needed (1.8 branch)]
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: