Vista Feature Comparison Recover Lost Bookmarks in Firefox Super Converter Best Lite Apps Track Packages
Collapsed Today Collapsed CyberNotes
Collapsed Yesterday

This May Help Your Firefox Memory Leak

March 26th, 2006
177 Comments Written by Ryan

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).

RSS Icon Enjoyed the post? Subscribe to our feed to get a daily dose of CyberNet!

Tags: Firefox, Software, , , ,

Learn Firefox
Previous ArticleNext Article
 

Related Posts:


177 Unread Comment Tracking CyberMark This Article
RSS Icon
177

  1. Avatar

    Fantastic, thanks!

    This issue is a real pain.

    I hope the next version will address this for good.

  2. Avatar

    I am glad this helped you!

    -Ryan

  3. Avatar

    d’oh i added config.trim_on_minimize as a string how can i change the type?

  4. Avatar

    You should just be able to delete the key you created and create a new one.

    -Ryan

  5. Avatar

    Wow! that’s freakin’ awsome! My mem usage went down from 88 MB after startup (thanks to session saver) to 8 MB with the windows minimized and then to 50 MB after opening everything agian. I have 14 tabs in two windows which is pretty typical.

  6. Avatar

    Yep, it works!
    If it didn’t diminish it as much as lucky Nate, it still cut it down at least in half when idle (even less sometimes).

  7. Avatar

    What a wonderful hack. I love it. Being someone that uses a LOT of tabs, the very simple thing of minimizing and bringing it back, removes MB’s of memory.

    Now its just a shame that we have to do this hack in the first place.

    Great find. I will be recommending this to everyone.

  8. Avatar

    This is an incredibly effective little hack.

    84MB after startup, and that was with only two tabs open, to 2MB when minimized and 32MB when refreshed!

    Kudoes to all involved.

  9. Avatar

    Super hack!
    With my typical ten tabs open mem usage cut from 56mgs to 9mgs on minimize. And…Firefox actually starts faster now:~ )

    Thanks a lot for sharing!

  10. Avatar

    No problem, this actually is a very popular ‘hack’ and can be found in other browsers by default. Opera and IE7 both have this feature enabled without user intervention, so I hope Firefox will follow.

    -Ryan

  11. Avatar

    Thanks for the story, I wrote my own and put a linkback to your site,

    Keep up the good work.

  12. Avatar

    Nice, very nice. Thank you!!!!

  13. Avatar

    This article is shity. Don’t call memory leak what’s not a memory leak.

  14. Avatar

    I CANT beleive this. You are a genius. Many many thanks. Just awesome.

  15. Avatar

    again…IE is still ahead of the rest

  16. Avatar

    Simply great!, thanks..

    :)

  17. Avatar

    Thanks a lot. This was very helpful, went from over 50 mb after just a few minutes of use, then minimized it, it went down to 6 mb. Then maximized it again and it was at only 18 mb. Very nice.

  18. Avatar

    Sweeeeeeeeeeeeeeeeet!

  19. Avatar

    works great thank you :)

  20. Avatar

    thanks for the article.
    i believe this is a feature not a memory leak though.

    @again…IE is still ahead of the rest
    so where do you set how many previously rendered pages are kept in ram in IE? :-)

  21. Avatar

    I don’t see why this is a hack, it is simply utilizing the features mozilla has placed in the firefox browser. I am glad people are finding those features useful though. :)

  22. Avatar

    will you “genius”es stop calling it a memory leak? it isn’t, the memory usage keeps rising because it is holding pages you have gone to in memory so that you dont have to wait for them to reload when you go back and forth… just stop calling it a memory leak and ruining firefox’s rep. and it doesn’t take a genious to look through firefox’s config…

  23. Avatar

    Yep!

    This isn’t a memory link, you’re trading ram for load/rendering time.

    http://kb.mozillazine.org/Brow.....al_viewers

    And also, tweak browser.sessionhistory.max_entries to a lower value as well.

  24. Avatar

    I am not saying that this is a memory leak, I am simply saying this may help the memory leak.

    -Ryan

  25. Avatar

    Argh where’s the delete option? I made a string.

  26. Avatar

    You should just be able to right-click on the string that you made and select Delete.

    -Ryan

  27. Avatar

    Great hack, man. Works like a charm. Took the liberty and published a portuguese version of the trick here. With a full source acknowledgement, of course.

  28. Avatar

    Thanks man, it is always good to get articles in as many languages as possible :) .

    -Ryan

  29. Avatar

    Firefox does contain a memory leak. Because as you visit pages and add tabs the memory usage skyrockets, and never goes back down, till the point it causes the browser to crash. I use upto 40+ tabs at times and saw the memory usage above 240mb on occastion with an equal amount of virtual memory usage.

    Also intresting to point out with this hack, mind you Mozzila encourages the use of this word on there website http://www.mozilla.org/hacking/, is that if you have added counters for i/o reads and i/o writes, it will not access the hard drive very much. On my system it never read even 1mb from the hd and i actualy looked at every tab to make sure it wouldnt load them as i access them.

    And for the person pointing to the mozzila developer page
    http://kb.mozillazine.org/Brow.....al_viewers
    I suggest you go back and read the bugs at the bottom of that page

    Bug 274784 - Make back and forward blazingly fast and side-effect free

    Bug 292965 - Improve eviction algorithm for fastback/bfcache

    My advice is go with Opera 9 there beta builds are rock solid right now with weekly updates sometimes twice a week!!!

    And it has passed the Acid2 test unlike most browsers.

    You can find all the weekly builds here

    Browser Speed tests

  30. Avatar

    Mine was sitting 72 megs. I minimized, it dropped to 6 immediately. On bringing it back, it was at 14.

    This is awesome.

    To those at Firefox who claim there is no memory leak: Explain how with 5 tabs your browser takes up 286 megs on my machine then please. (And that’s with all the known memory hogging extensions removed.)

  31. Avatar

    Will this cause all extensions to stop functioning since the whole app is transferred to the HD, or will Gmail Notifier and the likes still work?

  32. Avatar

    All of the extensions should still function properly because not the WHOLE Firefox is transferred to the hard drive. It is always easy to revert back if it doesn’t work for you, so give it a shot.

    -Ryan

  33. Avatar

    Yeah, I guess you’re right. Giving it a shot won’t hurt too much. :P

  34. Avatar

    According to this slashdot article the memory leak is not a bug it’s a feature.

  35. Avatar

    Yeah, that is what everyone says, but after you disable that feature you will notice that it doesn’t help. I wish the issue was as simple as that though.

    -Ryan

  36. Avatar

    HUGE difference!! Thanks!

    Derek Hampton
    SouthBeachCasa
    http://www.southbeachcasa.com

  37. Avatar

    excellent, now here is an english hack for you… anyway never ends in an s.

  38. Avatar

    A memory leak is when allocated memory is no longer referenced, without being freed. Thus, even after you exit the program, the OS still thinks the memory is in use, when it’s NOT.

    Firefox does not have a memory leak. Firefox is a memory HOG, for sure, but it’s not a leak. Please stop causing confusion by using an incorrect term for what is happening.

  39. Avatar

    A memory leak is when allocated memory is no longer referenced, without being freed. Thus, even after you exit the program, the OS still thinks the memory is in use, when it’s NOT.

    Really? Where’d you get your CS degree? Better go get your money back… The OS will never think any memory is still allocated after a ‘leaking’ program exits. Never. Not even Windows. All memory allocated to the process is freed, regardless of whether the process itself was able to keep track of it.

    Firefox does not have a memory leak. Firefox is a memory HOG, for sure, but it’s not a leak. Please stop causing confusion by using an incorrect term for what is happening.

    You’re half right here. This problem is not a leak, but I can guarantee that FF does have memory leaks. Very few C/C++ programs are ‘leak-free’, so while you’re right about the cached pages not being a leak, your statement that FF doesn’t have a memory leak is patently wrong. There are leaks.

  40. Avatar

    This hack destroyed IE Tab icon in my forefox

  41. Avatar

    Sweet. Can you explain what does config.trim_on_minimize mean and where else can I find more preference settings other than on mozilla.org

    Thanks.

  42. Avatar

    winnar!1

  43. Avatar

    the one thing i dont understand is why dont people count the VM Size column too.

    applied the hack, and it seems to work allright, firefox trims to ~1.5mb on minimize, then grows up to 11mb again and stays somewhere in there.

    but the VM size column sits the same (read: 60megs+, with maxviewers set to 2), and I assume while this hack would help me keep firefox open for more time, it would probably end up committing its memory leaks to the swap file so gradually increasing that bit by bit.. nice hack, but i think we need more than that.

  44. Avatar

    WOW! Thanks for this, might make me finally make the switch to firefox, it always [used] to hog too much memory to be useable!

  45. Avatar

    This is a lifesaver. Thanks.

  46. Avatar

    This sounds very helpful to me. Good effort on this piece of information. My memory resource is very limited on my computer and I am trying hard to keep applications running to a minimum.

  47. Avatar

    Also the Clear Cache Button extension can remove 50mb in a click.

  48. Avatar

    didn’t work on my firefox 1.5.1 on OS X 10.4.6
    bummer.

  49. Avatar

    The guy who said that Windows apps can’t have memory leaks needs to check his basement for ram puddles.

  50. Avatar

    The guy who said that Windows apps can’t have memory leaks needs to check his basement for ram puddles.

    That gave me a good laugh :D .

    -Ryan

  51. Avatar

    None of the things you’ve listed are actually “memory leaks” — bloat perhaps, but not leaks. We hold on to a lot of data to try and keep the browser fast, but very little of it actually leaks.

    That said, there are some extensions that do cause real leaks and we’ve been working hard to resolve many of them.

  52. Avatar

    hey,

    my firefox is in my native language, and not english. could you please tell me which one is the “BOOLEAN”??

    (top, middle, bottom)??

    Thx

  53. Avatar

    The problem is only to a limited extent a memory “leak” the problem is *really* memory fragmentation. If you keep your browser open for days (as I do) and visit lots of pages (as I do) then you can slowly watch firefox’s memory usage creep up to several hundred K (you can watch it using vmstat or top under linux). Once it hits 60-70% of physical memory the machine will start swapping. These are almost always swap-ins as the memory manager (a combination of the garbage collector and/or the C “malloc” manager) goes throught the heap looking for memory to allocate.

    The problem even happens when you “Quit” from firefox — I’ve seen it take 15 minutes (on a Pentium 4) to close 20+ windows (150+ tabs) — all because its trying to free up memory and organize it into one large “chunk” before freeing it completely to the OS. This is ascerbated because Linux doesn’t seem to page-in the pages required at a rate as high as that the disk will support — this is a Linux tuning problem — it can be helped by tuning vm.swappiness but that isn’t a complete solution.

    The best solution I’ve found so far is to use the “Session Manager” extension to allow you save entire sets of sessiosn, then Quit Firefix and restart it and all of the windows & tabs. You will generally see a much smaller use of memory after restarting it.

    The problem will not be solved until they rewrite the internal memory management code to do more memory/cache management within the browser. It may be helped somewhat with the Bookmarks/History rewrite which is supposed to be in 2.0 — history records and bookmarks presumably grab a memory chunk every time you visit a page or add a bookmark and presumably contribute to the heap fragmentation. What needs to happen is the browser needs to use mmap() to create a private memory allocation heap for each page that you open — then when you close that page all of the memory gets returned to the operating system (presumably you want the history memory and bookmarks memory in their own private heaps as well). But the architecture as it currently stands is simply flawed by assuming that you can allocate & deallocate memory from the heap without being intelligent about it.

  54. Avatar

    I have written my observation about this hack in my blog. I think this hack works only for a short time.

  55. Avatar

    This only works under windows.
    On other OSs it does nothing.

  56. Avatar

    Thanks for that fix - nice to have when you’re running lots of programs daily.

  57. Avatar

    Makes exactly ZERO difference for me. Perhaps this only works with windoze?

  58. Avatar

    This article has been of great help to me. Thanks for posting.

  59. Avatar

    Robert Bradbury,

    Very insightful comment, thanks for the information.

    -Ryan

  60. Avatar

    Nice hack. No matter what you call it.

    I don’t anticipate deleting, but tried as test, and do not get a delete option when I right mouse click it. Am I missing something? You mean while at the about:config screen, yes? where it says “user set/boolean/true”?

  61. Avatar

    Sorry, I could have sworn there was a delete option, but all you have to do is toggle the value to false.

    -Ryan

  62. Avatar

    Same comment as 43 (george)

    It changes nothing.
    the VM size remains the same.