How to fix the Firefox memory leak (Firefox hack)

Firefox memory leak? It doesn’t have one. Unfortunately, because of the way it’s configured to run out of the box it *looks* like it has one.

Follow these simple steps to get your Firefox memory usage under control.

These configuration changes are a trade-off between internet browsing speed and memory usage. They are most useful if you are multitasking and need Firefox to be less of a memory hog while using other applications.

#1: about:config

Type “about:config” into your address bar to access the hidden configuration options for Firefox.

firefox-memory-leak.png

#2: browser.cache.memory.capacity

Controls how much memory is used to cache pages.

Right click on the page and choose New then Integer and create an integer called browser.cache.memory.capacity and set it to a low number. This controls how many kilobytes of memory are used for the browser’s cache.

NOTE: number in screenshot is too small. Aim for 80% of whatever the default is.

firefox-memory-leak3.png

#3: browser.cache.disk.capacity

Controls how much disk space is used to cache pages in kilobytes.

Set browser.cache.disk.capacity to between 5000 or 15000.

128MB to 512M -> 5000.
512BM to 1GB of RAM -> use 15000

firefox-memory-leak6.png

#4: config.trim_on_minimize (optional)

Configure Firefox to swap memory to disk when minimized. This will make Firefox less responsive if you minimize/maximize a lot, but it is good if you need to free memory while multi-tasking to other applications.

Right click on the page and choose New then Boolean and create a boolean called config.trim_on_minimize and set it to true. Now when you minimize the window it will free up memory.

firefox-memory-leak4.png

#5: network.prefetch-next

Network link prefetch will download all pages with the rel=”prefetch” tag. This uses up more memory than you would otherwise think.

Set network.prefetch-next to false.

firefox-memory-leak2.png

#6: browser.sessionhistory.max_total_viewers

This controls how many pages of history are kept in the back/forward buttons. Lower the value to something acceptable. If you do not use back/forward often then you can set this very low.
Set browser.sessionhistory.max_total_viewers to a low number.

firefox-memory-leak5.png

Related Posts

Further Reading

Ryan at CyberNet installs 200 Firefox extensions (via Rooster) and checks memory usage. It jumps from 145 MB to 195 MB after two hours (note that this is a worst case scenario).

Mozillazine article on reducing memory use in Firefox.

List of popular extensions that have memory problems.

Leak Monitor extension for detecting memory leaks.

45 Comments

  1. Matt Foxtrot
    Posted December 03, 2006 at | Permalink

    This is really useful! Thanks!

  2. Posted December 10, 2006 at | Permalink

    Awesome blog, great article. I added it to my blogroll, hope you don’t mind. I really like what you were able to do with Sandbox - if I do not have to purchase the CSS upgrade to mod it, I may switch over myself.

  3. Posted December 11, 2006 at | Permalink

    Thanks symbolik.

    It’s comments like yours that keep this fun to do.

    The CSS upgrade was a *lot* of work (I’ve never used CSS before), but it was more satisfying than dealing with a pre-packaged theme and the issues most of them have.

  4. Posted December 28, 2006 at | Permalink

    Only I can manage to screw this up. I managed to create a key with String instead of Integer for the first one, and now I can’t change it! ggrrr.

  5. bltz
    Posted January 03, 2007 at | Permalink

    Thank you - excellent tips and all in one page.

    Added to my ff settings. :)

  6. Connor
    Posted January 23, 2007 at | Permalink

    Wow, your firefox hack is awesome. I kept watching firefox use more and more memory till it finally would crash. Very annoying and I couldn’t find a solution anywhere. Then, once I noticed how much memory firefox would use when it was active for awhile, I realized it was a memory leak. A little googling and then I discovered this blog. What a difference it’s made in Firefox’s performance. Muchas Gracias for sharing this knowledge.

  7. Posted January 23, 2007 at | Permalink

    I’m glad you found it useful. It really is essential to getting Firefox to work.

  8. Posted January 27, 2007 at | Permalink

    I’m suprised this isn’t better known - even among the incredibly IT-savvy people I know, they see this memory leak as an insoluble problem. I’m looking forward to sharing this article with them, as the “memory leak” is probably the most-publicized Firefox fault.

    Many grateful thanks!

  9. Posted January 27, 2007 at | Permalink

    The other big cause of memory problems with Firefox is Flash… but I think that was fixed in the latest Flash update.

  10. Greg
    Posted February 02, 2007 at | Permalink

    Of course, all of these settings, while they will reduce memory usage, will do so at the cost of speed. Caching more results will make pages load faster. If you have the RAM to space, you might not want to make these changes.

  11. Alan Grossberg
    Posted February 02, 2007 at | Permalink

    Can’t you also change the cache settings from Tools/Options/Privacy…or is that different from tweaking them in about:config?

  12. Posted February 02, 2007 at | Permalink

    @alan:

    Tools/Options/Privacy is for clearing the cache. About:config is used for setting values for disk/memory cache.

    Different things.

  13. Michael Fremlins
    Posted February 02, 2007 at | Permalink

    There’s a problem with #2. You say “This controls how many megabytes of memory are used for the browser’s cache.” But on the Mozilla site here (http://kb.mozillazine.org/Browser.cache.memory.capacity) it says this value is kilobytes.

  14. Posted February 03, 2007 at | Permalink

    @Michael:

    Thanks for that. Corrected.

  15. Posted February 03, 2007 at | Permalink

    thx a lot man.

    it’s all, see ya.

  16. _Jon
    Posted February 03, 2007 at | Permalink

    Thanks for the suggestions.

    Can you offer a better suggestion for #2 other than “80% of the default”? If this is a new key, I don’t know what the default is. Something like what you have done for #3 would make this excellent list even better.

    Thanks

  17. Brian
    Posted February 03, 2007 at | Permalink

    It is utterly ridiculous that a user should have to go through that many steps to get Firefox’s memory “under control.”

  18. sven
    Posted February 03, 2007 at | Permalink

    OR you can just change:

    browser.cache.memory.leak

    from 1 to 0

  19. JoeB
    Posted February 03, 2007 at | Permalink

    I hope you like looking at that huge number of unused memory in the Task Manager.

  20. Posted February 03, 2007 at | Permalink

    @Jon: The defaults are as follows. Use a smaller number.

    Physical RAM Memory Cache (in KB)
    32 MB 2048
    64 MB 4096
    128 MB 6144
    256 MB 10240
    512 MB 14336
    1 GB 18432
    2 GB 24576
    4 GB 30720
    8 GB and up 32768

    @JoeB: “I hope you like looking at that huge number of unused memory in the Task Manager.”

    Did I need to prefix this article with “only apply if you’re having memory problems”? I run a VM-Ware linux machine on my desktop that uses up all available memory. I like to keep Firefox opened for quick reference, but I want to free the memory for VM-Ware when Firefox is minimized.

  21. Alan Grossberg
    Posted February 03, 2007 at | Permalink

    engtech…thanks for the reply, but I’m still confused. I’m using Firefox 1.5.0.9, and under Tools/Options/Privacy there’s a box where I can manually set the number of MB of disk space for the cache. Is that different than using about:config? Thanks.

  22. JoeB
    Posted February 03, 2007 at | Permalink

    I submit that your VMWare problem is special and that ordinary Firefox users have plenty memory to spare on caching. I can’t fathom why someone would sacrifice usability for a large amount of free and unused (!) memory.

    Presenting these hacks without clearer caveats does everyone a disservice.

  23. Posted February 03, 2007 at | Permalink

    @Alan: That’s for disk cache, so it may be the same as #3.

  24. Posted February 03, 2007 at | Permalink

    @joe: This is a guide for people who have memory issues with Firefox, not a guide for people with a large amount of unused memory.

  25. Jordan Bacho
    Posted February 13, 2007 at | Permalink

    If your tips are so good then why doesn’t Mr. Firefox include them by default? I smell something fishy here.

  26. Posted February 14, 2007 at | Permalink

    Thanks - I’d been having a memory leak problem, hopefully this will do the trick.

  27. Ricky Bobby Joe
    Posted February 14, 2007 at | Permalink

    Heh, there’s nothing fishy about this. Back before Firefox was “a gleam in someone’s eye”, Mozilla (the browser) had a similar but opposite issue. When you maximized a browser window after having it minimized for some time, it took a very long time to come up. Searching their forums way back then, I found the solution: add “config.trim_on_minimize” to about:config and set to false. These days most people have much more RAM to allocate, so the devs take advantage of that, by default.

    You can’t just type some random thing and have it affect the browser. Firefox has to recognize the entry, and if it does, that means it was designed to.

    It would be nice if they would put some sort of easily accessible Advanced Settings panel in so users could make changes to suit their preferences regarding memory usage. But given the average user, they probably feel it’s best to keep these settings hidden.

  28. matt
    Posted February 27, 2007 at | Permalink

    I made your requested changes and saw memory usage drop by about half. However since I made the changes firefox crashes on me 2-3 times per day. Since almost 90% of my work involves the use of ff I guess I am going to go back to original settings. I am using the latest version of ff and it is (unfortunately) running on windows crappy (i mean xp). Has anyone else had crashing problems after making the above changes? did you solve them with out reverting to the original firefox settings? Thanks for any help or tips.

  29. Posted March 14, 2007 at | Permalink

    THANKS!!!

  30. X-J
    Posted March 22, 2007 at | Permalink

    Thank you for your great tip, my firefox works great now!!

  31. KipHT
    Posted March 31, 2007 at | Permalink

    My firefox never crashes but it does use over 150MB if left un touched for hours and hours. Thanks for these tips, I hope they help

  32. visitor
    Posted April 18, 2007 at | Permalink

    I have noticed that excessive CPU usage by Firefox occurs in conjunction with excessive memory usage. The “MultiMeter” downloadable sidebar gadget for Vista is helpful in monitoring this. I currently use Firefox 2.0.0.3, and it has the setting “browser.cache.disk.capacity,” but not the option “browser.cache.memory.capacity.” Anyone know why this is missing?

    PS: May I suggest that your blog entries should have dates attached to the titles?

  33. Hande
    Posted April 26, 2007 at | Permalink

    Hi,
    thanks for all the tips, I am having memory issues with firefox, it seems to “hang” at times and doesn’t react to tab changes or when writing something it just stops….
    I applied the above “hacks” but the trim on minimize doesn’t seem to do anything…. I am around 200 mb, the about:config shows that I have set true for this but still, when I minimize it doesn’t go down a bite! (I have restarted firefox and even the PC completely) Do you have any idea why this doesn’t work?

  34. Jay Armstrong
    Posted January 12, 2008 at | Permalink

    just another big thank you. :) FF was hitting 400 MB of memory in Windows and in Linux. With the combination of tab-mix plus, the tab-close-undo option, FF’s memory, and running ~20 tabs. I knew what was causing it but didn’t know where to fix it — now I do.

  35. carmen schmidlap
    Posted January 30, 2008 at | Permalink

    i don’t use firefux.it has so many
    security flaws it looks like a piece of swiss cheese

  36. Gilbert Wham
    Posted March 19, 2008 at | Permalink

    150??? Christ, I’d *love* that! Mine was using 880Mb today Eight hundred and eighty.

  37. Posted March 19, 2008 at | Permalink

    @ Gilbert Wham:

    One person I know regularly complains about GIGs of memory being eaten up by Firefox.

    The good news is that Firefox 3 (out soon) fixes most problems.

  38. Posted April 08, 2008 at | Permalink

    Thanks for this! Firefox was up to 1,400 MB today. I was getting fed up with it. I work with ColdFusion and Dreamweaver, don’t know if the constant refreshing, multiple CSS and JS includes make it worse. But I’m very happy to see that it’s been addressed.

  39. Dave
    Posted April 10, 2008 at | Permalink

    @carmen schmidlap & maybe others

    what is it you don’t like about swiss cheese? most of them don’t have any holes at all, so it may just look as you don’t know what you’re talking about. and considering the holes iexplore definitely has, it’s all about chosing a software that suites your needs and doens’t ruin your computer as soon as you have it running (or installed? sorry if you’re running windows, because then it seems you don’t really have much of a choice or do you?)

    ps: yes I’m swiss. and I love good cheese. and maybe some people should stop eating crap that comes out of cans that only have “cheese” written on the label but has nothing to do with the real stuff (this also applies to chocolate-flavoured strawberries, blue chocolate and bright-red-but-tasteless tomatoes). if you quit buying this crap, well maybe they’ll stop selling it. oh yeah, this also applies to software.

  40. Johnny
    Posted May 10, 2008 at | Permalink

    When I did this, my Firefox MB usage shot up to 70MB! Is that supposed to happen?

  41. Richard Watt
    Posted May 23, 2008 at | Permalink

    Wow, thanks!

    so clear and fast!

    now i`ve gotta do it to the rest of the office heheh

    Gracias compadre!

  42. Posted May 26, 2008 at | Permalink

    @ Richard Watt:

    At this point I would just wait for Firefox 3.

    Firefox 3 will fix this memory problems.

  43. jeepboy93
    Posted June 02, 2008 at | Permalink

    I found an great to get your ram usage to 30,000mb.
    go to the about:config screen like always,now find these two codes and turn them to false.

    look up this: network.http.pipelining.ssl
    network.http.pipelining

    now reboot your browser and e-mail your results to me at
    evan93333@yahoo.com

  44. biz888
    Posted July 01, 2008 at | Permalink

    You are awesome! My firefox works now. I don’t mind donating to a site like this. I am very happy.
    Thank you.

  45. Posted July 17, 2008 at | Permalink

    Wow!
    Nice tips, thanks for sharing

31 Trackbacks

  1. [...] How to fix the Firefox memory leak (Firefox hack) « //engtech (tags: firefox memory leak fixes?) [...]

  2. [...] How to fix the Firefox memory leak (Firefox hack) (tags: software) [...]

  3. [...] Fixing the Firefox Memory Issue [...]

  4. [...] How to fix the Firefox memory leak (Firefox hack) « //engtech (tags: firefox hack tips sysadmin) [...]

  5. By links for 2007-02-04 at DeStructUred Blog on February 04, 2007 at

    [...] How to fix the Firefox memory leak (Firefox hack) « //engtech (tags: Firefox Hack) [...]

  6. [...] Bu adreste bulunan yöntemlere göre düzenlemem sonucunda %30 oranında performans artışı sezdim. Firefox 2.0′ı düşük hafızalı bilgisayarlarda kullananlar için gayet güzel bir çözüm gibi görünüyor. Ozan Kilic05/02/2007           0 kez pohpohlanmış “Firefox hafıza problemine bir çözüm” başlığına kimse yorum yazmamış [...]

  7. By Daily Links | CreativeBits on February 08, 2007 at

    [...] How to fix the Firefox memory leak (Firefox hack) [...]

  8. [...] 目前最令人頭痛的問題之一,應該就是 memory leak。今天從 //engtech 看到 How to fix the Firefox memory leak [...]

  9. By Kreativgemüse » Memoryleaks in Firefox? on February 12, 2007 at

    [...] als man es ihm zutrauen würde… Viele Sachen kann man letztendlich abstellen, wie dieser Artikel zeigt. Naja… Fand’ ich wichtig mal zu [...]

  10. By Tech Tips » on February 21, 2007 at

    [...] Have you noticed that Firefox can be a memory hog (still not as bad as IE7), especially when you have lots of tabs open? This might help. [...]

  11. [...] engtech 的文章 “How to fix the Firefox memory leak (Firefox hack)“,有五個 Firefox 的隱藏設定可減低 Firefox [...]

  12. [...] up many results on “Firefox leaking memory”, but nothing solved my problem. I tried EngTech’s solution & couple of other solutions. More tinkering around pointed me out to a plugin, which was the [...]

  13. By award tour » firefox memory options on April 30, 2007 at

    [...] How to cahnge how much memory Firefox uses. couple interesting options you can play around with. [...]

  14. [...] this problem, I was quite glad to find this tutorial on how to solve the Firefox memory leak: how to fix the Firefox memory leak (Firefox hack). I followed the instructions and have been able to improve Firefox’s memory usage efficiency, [...]

  15. [...] searched and even this article was not able to help till much extent. Starting firefox will take the memory usage to 60k memory . [...]

  16. [...] : Voici deux autres liens qui peuvent aider : How to fix the Firefox memory leak (Firefox hack) reducing memory use in Firefox Encouragez-moi en soumettant cet article aux digg-like : Ces [...]

  17. [...] Sumber artikel dan gambar diperoleh dari situs Internet Duct Tape. [...]

  18. [...] http://internetducttape.com/2006/12/02/how-to-fix-the-firefox-memory-leak-firefox-hack/ [...]

  19. [...] been hacks to solve this problem n MozillaZine, and a summary version of the hacks can be viewed at InternetDuctTape. It is a hack, a suggestion on how to optimize memory usage of Firefox for your computer [...]

  20. [...] How to fix firefox memory leak (firefox hack) [...]

  21. By Hemat Memori Firefox « aku dan kehidupan on December 16, 2007 at

    [...] Untuk lebih lengkapnya dapat Di peroleh dari sini [...]

  22. [...] when Firefox crashes because of memory problems I don’t have to wait five minutes for the  error reporting dialog to pop-up. This entry [...]

  23. By firefox memory leak - Tech ARP Forums on January 22, 2008 at

    [...] i hear it gets worst the more RAM you have on your system. does this happen to you? i tried this and i guess it does help it a bit. but seriously disheartening to find my RAM being eaten up so [...]

  24. [...] I would run a search on this, hoping to find a solution. And luckily I did. This website explains how to fix the Firefox memory leak. Let me summarise the [...]

  25. [...] couple of tweaks to “temporarily solve” this issue. For those interested, you can read How to fix the Firefox memory leak with a couple of interesting [...]

  26. By links for 2008-02-16 -- Chip’s Quips on February 16, 2008 at

    [...] How to fix the Firefox memory leak (Firefox hack) « // Internet Duct Tape Reining in the ravenous red panda (tags: firefox memory hack howto browser tips) [...]

  27. By Irregular Enterprise mobile edition on March 22, 2008 at

    [...] while I’m in Mozilla flame mode, exactly when will Firefox stop leaking memory like a sieve by default and routinely bringing my machine to a grinding halt? That would be a much [...]

  28. [...] is your own words: And while I’m in Mozilla flame mode, exactly when will Firefox stop leaking memory like a sieve by default and routinely bringing my machine to a grinding [...]

  29. [...] How to fix the Firefox memory leak (Firefox hack) « // Internet Duct Tape config.trim_on_minimize (tags: firefox memory tips) [...]

  30. [...] Check this out… I have a feeling this will explain what is happening on your system…. Firefox Memory Usage __________________ Yes…. I Am Teh MeTh0Dz….. And, Yes…. I Like Teh [...]

  31. [...] than necessary. While there are several places that you can read up on this, I would recommend the Internet Duct Tape blog and the mozillaZine article, “Reducing Memory Usage.” I ended up changing some of [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*