Closed Bug 391933 Opened 17 years ago Closed 14 years ago

Memory leak in firefox on pages with big number of images

Categories

(Firefox :: General, defect)

2.0 Branch
x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: youonly, Unassigned)

Details

(Whiteboard: [closeme 2010-05-25])

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070809 Fedora/2.0.0.6-2.fc8 Firefox/2.0.0.6
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070809 Fedora/2.0.0.6-2.fc8 Firefox/2.0.0.6

Huge memory used by X server process when firefox open several pages with 100+
images inside (I used locally created pages with photos collection). Even after
firefox closed tabs with this pages, X server still used tons of memory. Only
after full termination of firefox, X server frees memory.

For example now X used 400Mb VIRT/167Mb RES of memory.

Opened 3 pages in tabs each with ~100 of 1024x768 images.

Got more memory used by X (862/535Mb):

 2150 root      20   0  862m 535m 8916 S    2 26.7 127:15.07 X

Closed tabs with that pages. The same result:

 2150 root      20   0  865m 539m 8916 R    6 26.9 127:16.86 X

This is 100% memory leak.

The only way to avoid swapping is full restart of firefox.



Reproducible: Always

Steps to Reproduce:
1) Create 5 local html pages with 100 images per page 1024x768 each.
2) Note memory used by X process.
3) Open all 5 pages in firefox tabs.
4) Note memory used by X process.
5) Close firefix tabs.
6) Note memory used by X process.
7) Exit firefox.
8) Note memory used by X process.
Actual Results:  
Overswap/system down when continuous using of firefox.

Expected Results:  
Firefox must free memory resources.

Tested same pages under Opera 9. No huge memory used when opened all pages (i.e.
Opera used different way to allocate X server resources?). Also X server
memory's goes lower after closing of Opera's tabs.

Some comments:

1) Not only X server memory problem. Firefox process leaks too:

189 VIRT/63 RES before open pages

328 VIRT/204 RES after open pages and the same after closing tabs with pages!


2) This is the browser cache keeping things in memory so it is very quick if you
want to go back to the same page you once visited.  If you don't want this, you
can disable the feature.  There are several preferences.  Load up about:config
and search for 'cache' and you can tweak to your liking.

3) This is bad idea to keep cache for closed tabs!!! Most of users never use "Undo
closed tab" feature. So actually this is memory leak which don't allow continuos
using of firefox when surfing big pages.

So best solution will be cleaning cache for closed tab. IMHO ;)

-------------------------------------------------------------------------------
4) This bug is *much* deeper.

Have just disabled memory cache (browser.cache.memory.enable=false)

firefox-bin process no more eats huge memory, it's ok

But X process still have problem. I opened 20 pages 100 images each, X grows to
 ~800Mb RES/1200Mb VIRT memory used even after I closed all tabs in browser!

Maybe there is some tool to view X resources allocated by process?
Seems firefox just not free some resources.
-------------------------------------------------------------------------------

Here is my original post to redhat bugzilla:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=249947
A webpage (and its images) are not released immediately when a tab is closed, because there's also the backward/forward cache. This is used to go quickly to a previous page, but is indeed also used to re-open a closed tab. The memory will be released when the page is removed from the bfcache, but it might take a while. Closing a tab is not enough, you need to load other pages as well.

If you want to disable the bfcache, you'll use a lot less memory : http://kb.mozillazine.org/Browser.sessionhistory.max_total_viewers
This is not right way.

Just set browser.sessionhistory.max_total_viewers=0
(and even try with browser.cache.memory.enable=false also)

The problem is NOT gone. firefox-bin process not using huge memory with this settings. But X process still use >1Gb of memory even then all tabs closed.

99% sure that firefox don't free some X server resources...

Versions used:

firefox-2.0.0.6-2.fc8
xorg-x11-server-Xorg-1.3.0.0-17.fc8
about:cache now shows only Disk cache device
So memory cache is totally disabled.

But problem with X server process still exists.
It uses tons of memory after surfung pages with larger images number...
To comment #1, the tool you are searching is xrestop. And I see the problem as well.
Any chance to fix this bug in 2.0.0.7 version?
I would suggest that you try out Firefox 3.0 beta 2 : <http://www.mozilla.com/en-US/firefox/all-beta.html>. That behaves a lot better, and will remove images form memory after 45 seconds.
This bug was reported on Firefox 2.x or older, which is no longer supported and will not be receiving any more updates. I strongly suggest that you update to Firefox 3.6.3 or later, update your plugins (flash, adobe, etc.), and retest in a new profile. If you still see the issue with the updated Firefox, please post here. Otherwise, please close as RESOLVED > WORKSFORME
http://www.mozilla.com
http://support.mozilla.com/kb/Managing+profiles
http://support.mozilla.com/kb/Safe+mode
Whiteboard: [closeme 2010-05-25]
Version: unspecified → 2.0 Branch
current version is ok
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.