This May Help Your Firefox Memory Leak


Now, this is by no means a REAL fix for the Firefox memory leak, but it certainly does appear to help it quite a bit. This little fix will move Firefox to your hard drive when you minimize it, and as a result it will take up less than 10MB of memory while minimized. So far, from my experiences with using this today, when you maximize Firefox it will obviously increase the memory usage. However, it does not seem to go back up to the insane amount that it was at before minimizing it. For example, Firefox was at 180MB of memory usage and then I minimized it and after a few seconds I maximized it. After maximizing it and continuing on my routine business it appeared to only have gone up to 60MB. This seems to be a good solution for me right now since I frequently maximize and minimize Firefox anyways.

Now I know many people will say that Firefox will take longer to maximize since it will be located on the hard drive, but I haven’t noticed ANY delays. It is able to redraw itself just as quickly as if it was located in the ram (in my experience). Okay, now here are the few simple steps:

  1. Open Firefox and go to the Address Bar. Type in about:config and then press Enter.
  2. Right Click in the page and select New -> Boolean.
  3. In the box that pops up enter config.trim_on_minimize. Press Enter.
  4. Now select True and then press Enter.
  5. Restart Firefox.

See how quick and painless that was? At any rate you can always go back and delete the same setting that you just created if you start to experience any issues. I have also set the browser.sessionhistory.max_total_viewers value to 0 because that will prevent Firefox from caching pages for the back button. This is also supposed to free up some memory that gets stolen.

Update:
Martin has informed me that this fix also works for Thunderbird. I am not a Thunderbird user so I didn’t realize this. After thinking about it I realized it “should” also work for Netscape, Mozilla, and SeaMonkey. Also, this fix is only for Windows machines (sorry Mac users).
  1. Great fix! It was becoming a pain having to close firefox.

  2. I played with it. My memory usage for Firefox with 20 tabs open is usually c.a.40 MB. After the tweak it showed 11 MB when minimised but went up to 27 MB after a short while. Maximised use 16 MB but went up to 36 MB after a minute or so.

  3. Thanks, Youre Great!

  4. Thank-u so much…got back at least 50% of my memory back…..

  5. After applying the hack I opened Firefox and the task manager and I notice that even though the RAM decreased after minimizing/maximizing it began to grow and grow slowly and I only had the Google page opened… it went from 12MB to 15MB and growing… is it normal?
    Regards.

  6. Yes, it is normal for it to grow slightly, but it will often not grow all the way back to the full amount.

    -Ryan

  7. Thanks for your answer Ryan.. I noticed that it grows but not to the same amount of RAM before. Regards.

  8. Thanks Ryan. That sure helped me a lot. You surely made my day…

  9. THANKS RYAN!! you are the man ;)

    The only change I have done is to the max viewers number as when I did set to 0 it didn’t load some sites properly (specially flash ones) and I just increased the number to 1 user, now everything works perfectly (I have been checking with the Task Manager memory usage every time I opened a new tab and closed them and all goes perfect)

    As all the other users say thanks for the work and help you have provided us.

    All the best!

  10. No problem. I am glad it worked out for you!

    -Ryan

  11. Is that string in the js file
    user_pref(”config.trim_on_minimize”, true); or

    user_pref(”config.trim_on_minimize”, true); without the semi-colon at the end? Thanks Dave

  12. Oops that should have been
    user_pref(”config.trim_on_minimize”, true) without the semi-colon

  13. So, this config option seems to work just fine. But then after FF has been minimized for a while, I note that the memory usage (accorging to Windows Task manager) has boosted back up to where it had been before. (One tab open, 90K memory!). Why?

  14. This tweak does not fix the memory leak, it tries to make it less noticeable by moving some of the memory that firefox is using to the hard drive. Eventually a lot of the data that was moved to the hard drive will get moved back to the memory unless you maximize and minimize frequently.

    -Ryan

  15. ***JD42****
    Is that string in the js file
    user_pref(”config.trim_on_minimize”, true); or

    user_pref(”config.trim_on_minimize”, true) without the semi-colon at the end? Thanks Dave

  16. This also solves the alt+tab-after-minimise problem! Super nice.

  17. tony bandero: Hi – I’m just making a programmer’s guess here, but what I think is happening is this; the cache clearing algorithm is pants (well, buggy), so memory usage ratchets up with each page you visit. When you use this hack, the cached memory is periodically stored to disk and then resumed to RAM – this visits some branches of the cache reclaim algorithm in a different manner, and misses the bug, junking all the rubbish pages; a ‘magic fix’

  18. This trick / hack / whatever you want to call it fixed my leak / inefficiency / whatever you want to call it! I went from using nearly 250MB with 12 tabs to sub 80MB. I use the Auto Refresh function, which I’m sure exacerbates my memory usage, so this program is a lifesaver. I’ll just minimize FF each evening before packing it in and it won’t be frozen in the morning when I return.

    Great job. I hope Mozilla gets this bug fixed in the next release.

  19. gwhizkids,

    So far I have been running Firefox 2 (currently in the testing state) with very minimal memory leaks so I think they may have fixed some of the bugs that cause the most common memory leaks.

    -Ryan

  20. I think freeing up physical memory when minimizing apps is a default windows behaviour, which used to work with earlier firefox versions, so I guess it was intentionally changed in firefox, with whatever reason behind.
    The hack is great, even if you find drawbacks, you can change the boolean to false, but leave the variable there.

  21. thanks a lot ryan! u helped me a lot wit this hack!

  22. firefox has taken 150MB of my RAM :evil: with only one tab and no extensions installed. hope they will fix it in next release

  23. I have had very few memory leaks using Firefox 2 Beta 2 so I am sure they solved many of the problems.

  24. I tried this pref on my Fx2.0RC1, WORKS LIKE A CHARM!

    ZERO visual negative performance impact, protects my RAM from this memory-hungry giant, hopefully Fx’s excessive memory usage will be further repaired in the 2.0 release ;)

  25. AWESOME!

    Ryan and JaDe42……you guys rock!

    I have a system that had half a gb of 400 mhz DDR 3200 RAM……But after running Tbird and FF the system ran SO slow,…found that TBird and FF were really eating memory…as in ALL my memory! Between the two they would rack up something like 400 mb of memory or MORE! So my system was basically running off of virtual memory all the time…..I stopped using FF for a while and the problem decreased but the system still ran like crap after Tbird was opened for a while…..so I did what some troller wrote — I bought some more memory….upgraded with another full GB. So the system has 1.18 GB of memory….runs much better, but I saw that the two Mozilla products were STILL eating up memory and things started slowing down.

    Found you guys’ fixes and in no time at all, I think the problem has been diminished…at least now I can minimize them and get the memory back!

    I used Ryans approach for FF and J’s apporach for TB….

    Awesome guys!

    By the way, this is on FF version 1.5.0.7 and TB 1.0.7

    Shadango the grateful

  26. Thanks man! I’ve used this and it really helps! :)

  27. Your Welcome! I still use this in Firefox 2 even though the memory leaks are much fewer. That way I know if I need some extra memory that I just need to minimize my browser. Enjoy!

  28. Sounds good in theory, but doesn’t work. I’m on Windoze, and though my 180MB dropped to 73MB, after ~10 seconds of being minimized, it jumped back to 180MB and stayed there. Rinse and repeat gives the same results.

    10 seconds of work just isn’t enough for me. Here’s to hoping they can make it less of a hog in general…

  29. I’ve been testing out Firefox 3 which won’t be released until late this year, and the results seem to be much better. The memory usage is normally at a respectable 100MB.

  30. This sadly doesn’t work for Windows 98 (in case anybody wonders) :? .

  31. thanks a lot ryan! u helped me a lot wit this hack!
    rede banner troca de banner gratis

  32. No problem Rede!

  33. I assume I can check the mem usage by going to the task manager, but if my assumption is incorrect, where do I go to find it? Vista Home Premium

  34. You’re completely right. The easiest way to bring up the Task Manager is to just right-click on the Taskbar and select the respective option. Then just look for Firefox in the processes list.

  35. this option allows windows to SWAP out the memory. to the swap file. its still using the same amount of memory. still, good for people with tiny amounts of ram.

  36. Fantastic!
    7 tabs open – went from 111MB to 8.5MB
    Very nice!

  37. I’ve been using Firefox for 2 years now and it took me a lot of effort to stick with it at the beginning. But now I’ve had it with this junk browser; don’t get me wrong, there are a lot of features that I admire and cannot live without but when it comes down to being a system hug, nothing beats Firefox. It doesn’t load pages with ample amount of comments i.e. this page or any page that has 100’s of comments on it. To the contrary, IE 6+ loads the same page in less than a second. I don’t know if the browser attempts to reconnect for every piece or just have a down right inadequate “rendering” capability. Most of the plug-ins such as Adobe Acrobat go haywire or crash FF after every update. I’ve had FF 1.0 up to 2.0.0.10 at this very moment and they all, without an exception, leak memory to the point where I have to utilize that redundant minimization technique. I’ve tried to turn off most of the plug-ins and what not in vain. There is no use…

  38. Wow! It is awsome! Right as you said!

  39. I loved this feature on my old XP machine, but it’s not working at all on my new Vista one. I’m assuming it’s a problem only with Vista. I followed the directions to a T, just like I did on XP, and there’s no change upon minimization. This was my favorite thing to ease the Firefox bloat.

  40. Kevin wrote:
    I loved this feature on my old XP machine, but it’s not working at all on my new Vista one. I’m assuming it’s a problem only with Vista. I followed the directions to a T, just like I did on XP, and there’s no change upon minimization. This was my favorite thing to ease the Firefox bloat.

    Vista reports memory usage differently than XP does, and so it is likely that it’s still working but you don’t see any differences in the Task Manager.

  41. It really works! Thanks for sharing this one.

  42. Can this hack be used with FF3? i had trouble doing searches. ram usage boost to 200mb with 5 tabs open.

  43. Doesn’t work for me in FF3

  44. Using FF3 and not working either, but maybe it’s a Vista 64 issue as I’m sure it works on my XP machine at home.

  45. Using FF3/Ubuntu and not working. :cry:

  46. very good, thank you

  47. Nice :) .

  48. Close but no cigar. It works but after a few seconds the memusage goes back to previous level.
    For example: before: 160,000K after, after minimize: 30,000K, seconds later: 150,000 and rising.

  49. My Firefox left running over night takes up over 1.3Gb of RAM. I can tell you things slow down…..lots, even on a Quad Core with 4Gb of Ram and 2TB hard disk space. This fix seems to be a message from heaven, an angel has landed and fixed Firefox. Even if it frees up a little ram (It has) it stopped my PC stuttering to a halt. Thank you..you have earned your wings…but don’t be like Icarus and fly to close to the sun…one step at a time yeah!!