Open Bug 411752 Opened 17 years ago Updated 2 years ago

Leak nsDownloadManager and more after downloading file

Categories

(Toolkit :: Downloads API, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: cbook, Unassigned)

References

Details

(Keywords: memory-leak)

Attachments

(4 files)

Attached file leag log
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b3pre) Gecko/2008011009 Firefox/3.0b3pre

Steps to reproduce: 
-> new Firefox Profile
-> download a file (in my case it was a 59 MB big file)
-> wait till the download is finished
-> Close Firefox with the download manager window open


nsStringStats
 => mAllocCount:          24058
 => mReallocCount:         3306
 => mFreeCount:           24056  --  LEAKED 2 !!!
 => mShareCount:          19468
 => mAdoptCount:           2214
 => mAdoptFreeCount:       2214
Flags: blocking1.9?
Summary: Download Manager Leak after file Download → Leak nsDownloadManager and more after downloading file
This looks like a bug in the download manager. One that looks bad to me given that downloading stuff is decently common.
Component: General → Download Manager
Flags: blocking1.9?
Product: Core → Firefox
QA Contact: general → download.manager
I don't think I'm seeing this bug.  Can you be more specific in your steps to reproduce, e.g. saying what action you took to start the download and to close Firefox?
(In reply to comment #2)
> I don't think I'm seeing this bug.  Can you be more specific in your steps to
> reproduce, e.g. saying what action you took to start the download and to close
> Firefox?
> 

Hi Jesse, yes sure:

My Download Manager Histroy contained before one entry before (also one mp3 File). Then i have downloaded http://www.newmixes.com/download/patrice_strike-club_fg_radio_fg-sat-01-07-2008-newmixes.mp3 (the idea yesterday was to test something for Bug 410680).

Download Manager is set to default setting = Show Download Manager ... and save all files to Desktop.

When i clicked on this download link above i got the "What Firefox should do with this File Dialog" and click on "Save File"

With Download Manager open i waited till the Download is complete and shutdown Firefox. I noticed also that the Download Notification bar was also visible when i closed Firefox, so maybe this could be one factor here.

In short my steps to reproduce today where:
Go to www.newmixes.com
Download one or more files
When the Download is complete and you see the Download Notification Bar
Close Firefox
Leak




Attached file leak log2
Leak Log from the testing today and the steps to reproduce from comment #3

nsTraceRefcntImpl::DumpStatistics: 769 entries
nsStringStats
 => mAllocCount:          32807
 => mReallocCount:         3994
 => mFreeCount:           32805  --  LEAKED 2 !!!
 => mShareCount:          30349
 => mAdoptCount:           3524
 => mAdoptFreeCount:       3524
Attached file complete debug output
maybe this helps
Attachment #296510 - Attachment mime type: application/octet-stream → text/plain
(In reply to comment #3)
> With Download Manager open i waited till the Download is complete and shutdown
> Firefox. I noticed also that the Download Notification bar was also visible
> when i closed Firefox, so maybe this could be one factor here.
What is the Download Notification bar that you are referring to here?
(In reply to comment #6)
> What is the Download Notification bar that you are referring to here?
> 

The small popup that comes up every times a download is finished. 
Attached file new leak log
new leak log from  Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b3pre) Gecko/2008012105 Firefox/3.0b3pre
Well, this leak makes sense if the nsIAlertsService box was still showing.  Does it leak when that goes away?  nsAlertsService holds onto a reference of the observer, which for the download complete notification, is nsDownloadManager:
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/components/alerts/src/nsAlertsService.cpp&rev=1.7#141
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/components/downloads/src/nsDownloadManager.cpp&rev=1.155#1834
(In reply to comment #9)
> Well, this leak makes sense if the nsIAlertsService box was still showing. 
> Does it leak when that goes away?  nsAlertsService holds onto a reference of
> the observer, which for the download complete notification, is
> nsDownloadManager:
> http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/components/alerts/src/nsAlertsService.cpp&rev=1.7#141
> http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/components/downloads/src/nsDownloadManager.cpp&rev=1.155#1834
> 

Yeah confirmed. You see the leak when you close Firefox with the download complete notification open, without its not leaking
So, is this invalid then?  It only leaks when nsIAlertsService is "working"
"Shutdown leaks" are still bugs that should be fixed, if only to make leak testing easier.
It's more like a race condition leak in this case - it's only if the nsAlertsService box is still visible.
It does make it a whole lot harder to find other leaks though. Especially since it's much harder to find regressions from N objects than from 0 since we have to keep track of what operations have "ok" leaks for what objects.

But I agree it's much lower priority to fix a leak like this than something that builds up over time.

But if you do have any info on what is going wrong here please do post it.
Not blocking on this since it won't affect end users. I.e. the "leak" is only there if you shut down at the wrong time. It won't accumulate over time.
Flags: blocking-firefox3? → blocking-firefox3-
Product: Firefox → Toolkit
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: