Elliott C. Back: Internet & Technology

Firefox Memory Leak

Posted in Browsers,Performance,Spread IE,Uptime by Elliott Back on February 20th, 2007.

Hi, my Firefox (the latest public version 2.0.0.1) is leaking memory. I know that you think you’ve heard this before and that it’s extensions, or old version, but seriously this has to stop:

Fixed! Removing the Firebug extension completely solves the problem. I don’t know why Firebug leaks memory, but trust me, it does.

firefox-memory-leak.jpg

Yup, it’s using 623MB of memory. Opening a new tab is visibly sluggish. Closing a tab, clicking on links–every action takes seconds to perform on my Core Duo 2 6600 processor with 4 GB of RAM. Extensions? I’m running two: Firebug and an S3 attachment:

firefox-extensions.jpg

The secret Firefox memory cache page (about:cache) returns nothing out of the ordinary:

Number of entries: 1114
Maximum storage size: 28672 KiB
Storage in use: 75316 KiB
Inactive storage: 0 KiB

I have no idea what’s causing this behavior, so I’m going to ask for help. Digg this and let the world know Firefox *still* has memory management issues.

This entry was posted on Tuesday, February 20th, 2007 at 11:21 pm and is tagged with . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

25 Responses to “Firefox Memory Leak”

  1. mlpilling says:

    Elliot, thanks.

    Removing firebug worked for me. I had the firefox problem when gmail was open as well – runaway memory which maxed CPU over a few hours. Bye bye firebug, bye bye problem. Go figure.

  2. NettiCat says:

    You are making a big mistake on how to measure the used memory of your processes.
    You read the MemUsage column but your are missing the virtual memory of each process, so itís only half the truth, in fact even less.

    On each OS, if a process memory (measured as MemUsage) reaches a defined size, a part of the memory is mapped into the virtual address space (VirtualMem). So the actual memory used will NOT increase, ‘only’ the virtual memory space increases constantly. Note that the virtual memory is allocated by the process and cannot be used by other processes, nor by the system! Virtual memory still is part of the appropriate process.

    So if you want know the real amount of used memory, then you have to ADD the values of MemUsage and VirtualMem for each process. To see the virtual memory you also need to display that column in your taskmanager as it is not shown per default. You will see a big surprise, it’s even a lot higher than shown in your taskmanager.

    The problem is, that only few people know how to correctly measure memory consumption of processes.

  3. Greg says:

    I don’t even know what Firebug is, and hence do not have it installed, and my Firefox has blossomed to 1.2 gigs!

  4. stone says:

    Why there always should be one idiot mentioning Opera in Firefox blog?

  5. JJ says:

    I have also had this same problem and I’m pretty sure that firebug is the issue. This issue is also documented here:

    code.google.com/p/fbug/issues/detail?id=127&can=4&q=

    I personally can’t live without firebug, so I suppose I’ll just have to restart firefox now and then.

  6. [...] I searched and even this article was not able to help till much extent. Starting firefox will take the memory usage to 60k memory . I dont know why !! Anyway Elliott found his problem fixed by uninstalling firebug and I was also left with no other option other than doing the same. I can say that it has improved my system performance to some extent. Keystrokes takes no more seconds to get identified. May be I will install firebug next when i will be developing my own theme now. Till then I am sticking to this 3column Pressrow theme. [...]

  7. Mark says:

    It was gmail for me – can’t have the thing open five minutes before Firefox is page faulting by the million. Run it in IE – no problem at all. I can’t remember which version of Firefox this started happening with, but a while ago I’d get the occasional ‘script misbehaving’ message. Now I can’t use gmail at all. I can’t go back to IE, so it looks like Opera, here we come.

  8. Mark Peterson says:

    Though I won’t be removing firebug anytime soon, it’s by far the best tool for creating non firebug related memory leaks, I’m glad to hear that others are experiencing the same problems.

  9. Heya! wow Firebug is the culprit? I’ve just disabled this extension, I need, need, need fast tabs, and the slowness in opening new ones with CTRL-T is driving me crazy. I will start typing the url, and loose the first five or six letters. ugh

    I even downgraded to 1.5 but left firebug active, now i’m uninstalling firebug I hope this works.

  10. Evgeniy Sinev says:

    I increase cache memory for firefox and firebug does not eat many memory.

    This is top output:
    PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
    5148 esinev 15 0 272M 195M 24464 S 0.0 5.0 13:40.38 /opt/firefox/firefox-bin

    prefs.js
    user_pref(“browser.cache.memory.capacity”, 100000);

  11. supplex says:

    you guys never heard of Opera?!

  12. Walt Collins says:

    Thanks for the tip about uninstalling Firebug. It seems to have really helped me so far.

    Prior to removing Firebug, my solution to the Firefox memory eating problem was/is to do this:

    1. Set my Firefox Option (on the Main tab, at the top) to: When Firefox starts “show my windows and tabs from last time”. This is a standard feature of Firefox.

    2. Install the Restart Firefox plugin.

    3. Whenever I notice that my system is sluggish, just restart Firefox. It basically does an in-place restart of all my tabs, seamlessly. This dramatically reduces Firefox’s memory footprint, only takes half a minute, and replaces everything I was doing including web form content and authentication.

    I can’t find any downside to this approach, so I’m quite happy to recommend it.

  13. Brian says:

    I’ve been tearing my hair out for the past week trying to figure out why my Firefox 2.0.0.3′s footprint keeps growing. Finally widdled it down to Firebug today (through my own trial-and-error) and I’m glad to see I’m not crazy.

  14. Your Face says:

    Funny. I’ve never had anything like that happen. Firefox 2.0.0.3 on my Linux box has been open since the 21st and is currently taking up ~60 MB (including swap).

  15. dror says:

    It’s firebug. I have the same issue. With firebug enabled it grows to 500-600Megs.
    With firebug disabled it stays around 200-300 Megs. I open and close tons of tabs. I might have 40-50 tabs open at one time.

  16. Kashif says:

    How about restricting cache memory capacity. I have set browser.cache.memory.capacity to 16MB

  17. Dravu says:

    Firebug has a major memory leak that has yet to be found. Like now for instance, I have Firebug enabled and FireFox is running on 160mb of Memory. But when I disable Firebug or uninstall it, I never have the memory leaks. It stores so much data on every page you view that after awhile of navigating and especially using tabs or looking at resource intensive pages, the memory just gets eaten right up. So even if you load a blank page, that Memory is still used up and won’t get freed until you kill the process. =/

  18. alan says:

    i find it’s GMAIL leaking memory in this fashion. if I open Gmail in Explorer then Firefox runs like it should.

  19. mupo says:

    I have the same Problem, even after some tunings in Firefox.

    The Problem in my configuration is Firebug!

    After the first start of Firefox it uses 60 MB.
    But then it is growing and growing, after some hours it uses 300MB and more, maybe Firebug is logging every action and so on?

    But disabling Firebug solves the Problem. It must be a bug in Firebug.

  20. SimonB. says:

    You could try installing the plugin "Nightly tester tools" and check the Leaklog , found in menu Tools – Nightly, or use this link:
    nightly/content/leaks/leaks.xul

    I’m not sure which kind of leaks are tracked on that page though.
    I had a bunch of crashes on Firefox 2. Never any on 1.5 or old Flock, so I’m suspicious that some recent features/changes that came into both Flock and Firefox should take the blame.

  21. hl says:

    visiting certain types of pages on one tab will cause a global cpu leak across firefox. it might be from flash or java or something else, i don’t know

  22. Cibbuano says:

    I’ve had the same problem with Firefox ever since ver 1.0. I’ve heard all the smoke waving, ie extensions, raw image storage, but I’d rather that the problem just go away.

    I can’t go back to IE, though. Firefox is like a new, shiny Leatherman, and IE is more like a rusted hammer that you use to open cans of paint.

    My solution? I use Firefox all day, and close it at the end of the day.

  23. Elliott:

    Thanks for pointing out about:cache. Didn’t know about that.

    Looking at the data on about:cache, it looks like it measures the cache size’s "in use" using the byte size of the original asset–but in the case of compressed assets (JPEGs, GIFs, etc.) it keeps the uncompressed data around in memory (have to verify this in the source). 32 MB cache of JPEGs coulud very easily be 600 MB worth of uncompressed image bits.

    If this is the case, this is one ****** cache management implementation.

  24. Elliott Back says:

    Yeah, that should add a constant overhead of 32mb. I’ve got 600+mb. Explain.

  25. LocalH says:

    Sorry about that, there was a left angle bracket in the text that caused the blog to clip it. Here it is edited to "less than":

    To improve performance when navigating (studies show that 39% of all page navigations are renavigations to pages visited less than 10 pages ago, usually using the back button), Firefox 1.5 implements a Back-Forward cache that retains the rendered document for the last few session history entries. This can be a lot of data. It’s a trade-off. What you get out of it is faster performance as you navigate the web.

    For those who remain concerned, here’s how the feature works. Firefox has a preference browser.sessionhistory.max_total_viewers which by default is set to -1. When set to this value, Firefox calculates the amount of memory in the system, according to this breakdown:

    32MB – 0 cached pages
    64MB – 1 cached pages
    128MB – 2 cached pages
    256MB – 3 cached pages
    512MB – 5 cached pages
    1GB – 8 cached pages
    2GB – 8 cached pages
    4GB – 8 cached pages

    (lxr.mozilla.org/seamonkey/source/docshell/shistory/src/nsSHistory.cpp#161)

    No more than 8 pages are ever cached in this fashion, by default. If you set this preference to another value, e.g. 25, 25 pages will be cached. You can set it to 0 to disable the feature, but your page load performance will suffer.

Leave a Reply