Taming Firefox memory usage

Firefox seems to eat memory like rats in a wheelie bin.

Successful programs often become so complicated that they are like operating systems in themselves, so complicated that they struggle with system type issues such as having perfect garbage collection, Firefox is one of these!

The irony is that Firefox's predecessor Mozilla, become too complicated, bloated and resource hugging. So Firefox was re-factored out of the code base as a small and fast browser. Now it is repeating the same cycle. This is not an entirely fair comparison, as Firefox has to deal with a Web filled with high resolution images, video and so on that Mozilla never did in its day.

Anyway, when Firefox goes into a crawl I have just ignored it, just restarting Firefox every so often when it hogs RAM. I also occasionally clear out the cache, history and all the other crap in the hope that it will help too.

I noticed today that I had only five tabs left open yet 86% of the laptop's memory is being used by Firefox, when I looked a bit further into it, a good chunk of that was on a process called npviewer.bin - i.e. Flash. 46% of my laptop's memory (2 GB) was being spent on Flash!

http://commandline.org.uk/images/posts/firefox/firefox_memory1.jpg

Finally something had to be done.

I decided to install an extension called Flashblock. This prevents the downloading of flash content until I agree to it, any Flash content is replaced by a play button.

Extensions can cause memory leaks, so I decided to remove all the extensions I don't use any more, and to disable ones that I use very rarely. We will see if my Firefox is now more nimble.

http://commandline.org.uk/images/posts/firefox/firefox_memory2.jpg

Memory Settings

One can set configuration settings to limit the amount of memory that Firefox uses to cache pages and store session history. As it happens, I decided not to do this yet, in order to see what effect the above steps I have taken make.

You can look at what is currently in Firefox's memory cache by putting this into the location bar:

about:cache?device=memory

So on the available settings. For each you need to type about:config into the address sbar, in order to add the settings.

browser.cache.memory.capacity

This limits the amount of memory that Firefox will use to store images. Set to the cache size you want in KB. So to set the maximum to 24MB give the number 24576.

browser.sessionhistory.max_total_viewers

This limits the amount of memory that Firefox will use to store old pages. This speeds up going backward and forward through pages.

config.trim_on_minimize

This one only works on Windows. If set to true, when Firefox is minimised, the cache is swapped from RAM to disk.

Browsers and speed

There is an adage I have often heard in mailing lists which goes something like this: 'Software can be fast, cross-platform or beautiful. Choose any two'.

The hope was always that the GNOME project would come out with its own light browser that would be beautiful and efficient, beating the lumbering yet cross-platform Firefox. After many promising developments in Epiphany and Midori, this has yet to happen.

So what browser do you use? Has your Firefox had slow moments too? Any good tips to share with us?

6 thoughts on “Taming Firefox memory usage

  1. <p>This is why Chrome is my default browser: I've never even felt the need to look for internal settings to tweak. It's also better looking and cross-platform so I'm not sure that quote is applicable. The lesson I'd take is a potent reminder that architecture matters: despite a long head start and, at least fir awhile, a larger developer community everything Mozilla-based has fallen behind the webkit browsers, I suspect in no small part because there's so much code to push around.</p>
    <p>(This is not to disparage the Mozilla devs, to whom the web owes a huge debt - and who are clearly working to stay in the game. I think it's more a huge reminder of how much avoiding complexity can be worth.)</p>

  2. <p>I'd try looking at Opera. The 10.60 version by some benchmarks beats chrome and it's feels very lightweight despite an amazing number of features built-in. It's also the first browser I've ever left smooth scrolling on because it works so well.</p>

  3. <p>I'd second Chrome as default browser. FF is still useful for web development, but for browsing Chrome rocks my world.</p>

  4. <p>I use this <img src="/static/forum/img/smilies/smile.png"></p>
    <p><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/67651/">https://addons.mozilla.org/en-US/firefox/addon/67651/</a></p>
    <p>it works <img src="/static/forum/img/smilies/smile.png"></p>

  5. <p>So that's what npviewer is? I always saw it in top but, I guess, was too lazy to Google it. I'll be taking these steps, thanks!</p>

  6. <p>FF uses lots of memory here, but then I typically have 500+ tabs open, cough.</p>
    <p>BarTab is a complete lifesaver, but even with that many empty tabs the memory and CP usage mount up.</p>
    <p>(Going through some old tabs, in an attempt to actually read / reply to them, and cut down the number!)</p>

How about Global Thermonuclear War? Wouldn't you prefer a good game of chess? Powered by zpress