Closed Bug 309381 Opened 19 years ago Closed 19 years ago

browser leaks large amounts of memory during normal browsing

Categories

(Firefox :: General, defect)

1.5.0.x Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 320915

People

(Reporter: beltzner, Unassigned)

Details

Attachments

(1 file)

After about 25 minutes of web browsing (intense surfing, jumping around between
pages a lot, opening tabs, closing tabs, never more than 3 tabs open at once) my
memory usage on w32 was up over 100MB. 

I tried the following actions to release memory. Sometimes a 200-1000 KB would
release, but most often, the memory usage would not go down:

  - closed tabs
  - set browser.sessionhistory.max_viewers to 0
  - opened a new browser window and closed the previous one
  - minimized the browser and let it sit for 5-10 minutes without touching

It doesn't seem to be related to bfcache (as I'd originally suspected) but
rather to some memory leak that occurs when a page is loaded / opened and isn't
released when that page is closed.

Confirmed on Windows using Firefox 1.4/20050919
Confirmed on Mac using using Firefox 1.4/20050919 and Firefox 1.6/20050920
Summary: browser leaks large amounts of memory during normal browsing → browser leaks large amounts of memory during normal browsing
Someone asked me on IRC if this bug report was meant to call attention to the
fact that Firefox hasn't historically had the best memory footprint figures, or
if it's meant to point out that since a recent bugfix, we're not releasing
memory when the browser is minimized.

The answer is neither: back when I was using Firefox 1.0.x, I recall that even
after days of being open, my memory usage for the browser would hover at around
10-40 MB depending on where I'd been and what was open at the time that I
looked. Now it's hovering at at three times that level, which is unacceptable.
This is possibly a dupe of bug 307018, although I don't think that the meomory
leak is restricted to tabs. I'll do some more testing tomorrow ... Deb, could
you test your memory footprint both with and without using tabs?
I have a very similar problem on Linux. FF seems to gobble up vast amounts
of memory in a few hours of intensive browsing, I usually have to shut it down
when it starts taking up 200+ MB.

I tried an experiment:
I logged in and started Firefox. It used about 28M (resident size).
I then opened 3 windows with a total of ~25 tabs (all loading regular HTML
webpages w/o plugins), memory usage went to 53 MB. Then I browsed around
without opening new tabs/windows, opening maybe 30-40 different pages in the
same browser window. That pushed mem usage to 78 MB.

Then I opened a single new window (Ctrl-N) and closed all others.
Mem usage stayed at 78 MB. Further browsing, however, did not seem to
increase it further.

(System: SuSE Linux, Linux 2.4.21, glibc 2.3.3, 512MB RAM)

Is this expected behaviour?
 
Some additional data points that I've discovered through testing (with one eye
on the Task Manager)

  - memory usage still climbs pretty rapidly even when not using tabs

  - as reported in comment 4, opening a new window & closing the original 
    browser does level things off a bit, although memory usage does still climb, 
    but more slowly.

  - it seems that interacting with content in a tab decreases the liklihood that
    memory will be released when that tab is closed:

Here's a testcase & observations. I used my weblog (http://www.beltzner.ca/mike)
as the "start" page, and opened the link to "gives insight into the decision
making process behind the new razor" (http://www.theonion.com/content/node/33930
about halfway down the page) using the right-click "Open in New Tab" function:

Action      Mem(K) notes
-------     -----  --------------------------
start       22980
  open bg   31684  alloc'd 8704
closed      28060  freed   3624 (diff = 5080)
  open bg   33664  alloc'd 5604
  focus tab 34172  alloc'd 508
closed      29724  freed   4448 (diff = 1664)  
  open bg   33184  alloc'd 3460
  focus tab 34400  alloc'd 1216
  interact  35952  alloc'd 1552
closed      34444  freed   1508 (diff = 4720)
A few observations:

 * task manager is a horrible measuring tool for memory leaks -- it uses some
standard of what pages are active, and minimizing affects that (although we may
have some influence on *how* minimizing affects it, and could even have changed it)

 * comparison to 1.0 probably isn't a great standard; 1.0 leaked all tabs (and
the last document in them) until the browser window containing the tabs was
closed.  That's fixed now (or at least was).
I performed the same testcase as in comment 5 on FFx 1.0.6, and came up with the
following statistics:

Action      Mem(K) notes
-------     -----  --------------------------
start       21436
  open bg   30200  alloc'd 8764
closed      24920  freed   5820 (diff = 2944)
  open bg   30176  alloc'd 5256
  focus tab 30548  alloc'd  372
closed      26616  freed   3392 (diff = 2236)
  open bg   31248  alloc'd 4632
  focus tab 31732  alloc'd  484
  interact  32972  alloc'd 1240
closed      29692  freed   1556 (diff = 4800)

The differences seem to be that we use more memory for focusing tabs in
trunk/branch than we did in 1.0.6, but other than that, the leak points look the
same. I think the reason why it never came up before might be that in 1.0.x when
you minimize the browser, it releases all the memory pools (in my case the
memory usage droped to 8000KB or so). We don't seem to do that anymore -- and I
believe that's by design.
(In reply to comment #6)

>  * task manager is a horrible measuring tool for memory leaks -- it uses some

Is there a better tool available?
So... loading http://www.theonion.com/content/node/33930 leaks all sorts of
stuff due to bug 241518.  That's not to say there are no other leaks here, but
they're being hard to see in the noise if they exist.
I may see this bug with the last few weeks of firefoxes I have tried. 
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.9a1) Gecko/20051018 Firefox/1.6a1

For example, while doing one of the 'browser buster' tests, memory is
increasingly consumed (~4 MB a minute), which will eventually render the browser
unusable or make the computer behave abnormally. During normal web browsing, I
experience a similar effect.

Tabs are not related to this issue for me. 


Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.9a1) Gecko/20051030 Firefox/1.6a1

I wanted to test whether active bookmarks (rss bookmarks) had anything to do with memory leaks, so I did some tests with active bookmarks in my bookmarks list, and without any in the list.

-----
TESTS:
-----

TEST: do not browse, just let browser sit doing nothing. Cache set to 30 MB max. Some Active Bookmarks are in the list of Bookmarks.
Before Start up, FreeSpace on disk was 210 MB

RESULTS:
(page shown was http://www.mozilla.org/projects/deerpark/alpha2.html) 

Time, FreeSpace on the Partition.

10:41, FreeSpace 190 MB
10:52, FreeSpace 194 MB
10:55, Freespace 186 MB
11:11, Freespace 190 MB
11:18, Freespace 186 MB
END TEST

Conclusion. No appreciable use of memory. No increase in memory use over time.
--------------------------

TEST: Some active Bookmarks are in the bookmarks list. Set the page to the browser buster: http://webtools.mozilla.org/buster/test_url_25.html

Time, FreeSpace

11:19, FreeSpace 162 MB
11:20, FreeSpace 158 MB
11:21, FreeSpace 153 MB
11:22, FreeSpace 149 MB
11:23, FreeSpace 141 MB
11:24, FreeSpace 133 MB
11:25, FreeSpace 124 MB
11:26, FreeSpace 120 MB
11:27, FreeSpace 116 MB
11:28, FreeSpace 107 MB
END TEST

Conclusion. An appreciable amount of disk memory was used, and the amount used increased quite rapidly over time.
-------------------------

TEST: Do browser buster test without any active bookmarks in the BookMarks file

Time, FreeSpace

12:58, FreeSpace 212 MB
12:59, FreeSpace 207 MB
13:00, FreeSpace 207 MB
13:01, FreeSpace 207 MB
13:02, FreeSpace 198 MB
13:03, FreeSpace 198 MB
13:04, FreeSpace 198 MB
13:05, FreeSpace 198 MB
13:06, FreeSpace 194 MB
13:07, FreeSpace 194 MB
13:08, FreeSpace 190 MB
13:09, FreeSpace 186 MB
13:10, FreeSpace 182 MB 
13:11, FreeSpace 181 MB 
13:12, FreeSpace 181 MB 
13:13, FreeSpace 181 MB
13:14, FreeSpace 180 MB
13:15, FreeSpace 180 MB
13:16, FreeSpace 179 MB
13:17, FreeSpace 179 MB
13:18, FreeSpace 179 MB
13:19, FreeSpace 179 MB 
13:20, FreeSpace 179 MB
13:21, FreeSpace 178 MB
13:22, FreeSpace 178 MB 
13:23, FreeSpace 178 MB
13:24, FreeSpace 177 MB
13:50, FreeSpace 165 MB
13:52, FreeSpace 164 MB
13:56, FreeSpace 163 MB
13:58, FreeSpace 163 MB
14:09, FreeSpace 163 MB
14:12, FreeSpace 155 MB
14:14, FreeSpace 151 MB
14:16, FreeSpace 142 MB
14:18, FreeSpace 130 MB
14:20, FreeSpace 122 MB
14:22, FreeSpace 117 MB
14:24, FreeSpace 111 MB
END TEST
----

Conclusion. If active bookmarks cause memory leaks, they are not alone in doing so in DPA2.

----
This problem still happens in Firefox RC 1.

I have just the plain browser installed, i.e. no extensions, themes, etc.
While browsing the memory keeps climbing from the initial and normal 20-30MB that I used to see in Firefox 1.0.7 to more than 100MB at which time the responsiveness has deteriorated so much that I shut it down and launch a new one.
I also tried to open a new empty tab and closing all the others and the memory still remained above 100MB.
It doesn't help much to open a new window and then close the current one, i.e. you realy need to close all browser windows before opening a new one so that the firefox.exe process realy terminates thus releasing the memory.
I think that this memory leak is severe and that it must be solved before the final 1.5 version is released.
I can confirm this on Linux with Firefox 1.5 RC 2.
Fox 1.5 WinXP SP2 - the same problem
Now I have more RAM, and I think that Firefox does not leak ad infinitum.  The memory usage increases during normal browsing (and restarting Firefox brings it down again), but it stops at some level -- I think around 80 to 100 MB.

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
18044 felix     16   0 97100  70m  32m S  0.0  7.9   0:00.01 firefox-bin
Blocks: mlk1.8
(In reply to comments #5 and #7)
These comments do not take into account possible filling of the Memory Cache Device.

*** This bug has been marked as a duplicate of 320915 ***
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
(In reply to comment #15)
> Now I have more RAM, and I think that Firefox does not leak ad infinitum.  The
> memory usage increases during normal browsing (and restarting Firefox brings it
> down again), but it stops at some level -- I think around 80 to 100 MB.
> 
>   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> 18044 felix     16   0 97100  70m  32m S  0.0  7.9   0:00.01 firefox-bin
> 
I've got 1.5 Go of ram on an xp SP1 system, and the memory usage by firefox (v 1.5.0.1), sometimes grows up to 700Mo with a single page opened !

No longer blocks: mlk1.8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: