Taming Firefox memory usage
15 June 2010
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!
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.
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?



1 Chris Adams says...
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.
(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.)
Posted at 9:13 p.m. on June 14, 2010
2 Dion Moult says...
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.
Posted at 7:35 a.m. on June 15, 2010
3 Skilldrick says...
I'd second Chrome as default browser. FF is still useful for web development, but for browsing Chrome rocks my world.
Posted at 6:38 a.m. on June 21, 2010
4 andrea says...
I use this :)
https://addons.mozilla.org/en-US/firefox/addon/67651/
it works :)
Posted at 1:57 p.m. on July 14, 2010
5 Ashley says...
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!
Posted at 3:34 a.m. on August 5, 2010