Saturday, February 21, 2009

Firefox using tons of memory

I have to admit, I love tabbed browsing. If I have 7 tabs open, that's low for me. I usually have at least 15 tabs open, sometimes up to 30. When I see an interesting link, I'll open it in a new tab to look at later. That way, I don't interrupt my train of thought.

The problem is that Firefox was using tons of memory. I was usually seeing memory usage near 600 MiB. This may not seem like much, but when you only have 1 GiB of RAM and want to use a Solaris VM at the same time, it tends to make your system come to a crawl because of virtual memory swapping.

So, I did a little research and found a fix. Now, the VM Size in Task Manager for Firefox is around 140 MiB, which is much more reasonable for me. The problem is that, by default, Firefox keeps a history of pre-rendered pages for each tab. With 1 GiB of physical memory, it defaults to 8 pages per tab. Multiply that by 15 tabs, and it's keeping 120 pre-rendered pages in RAM. Add lots of graphics to those pages, and it starts adding up very quickly.

Fortunately, Firefox is very customizable, so it's easy to fix. This page explains the details (that's a great site for Firefox tweaks by the way), but the short solution is this:

1) Type about:config in the Firefox address bar and hit enter.
2) Find browser.sessionhistory.max_total_viewers and change the value to 0.
3) Restart Firefox.

Before doing this, check the memory usage of your system and Firefox. Bring up Task Manager. If your Commit Charge is less than your physical RAM, it won't improve system performance. In fact, it would make going back and forth in the browser history (using the arrows at the top) a little slower in Firefox, since it will have to render each page every time you go back.

However, if your commit charge is greater than your physical RAM, it might help. Sure, you'll take a performance hit when it has to render every page again, but the performance hit caused by using virutal memory is much worse. To confirm that Firefox is eating up your RAM, go to View/Select Columns in Task Manager and enable Virtual Memory Size. Then, see how much Vitual Memory Firefox is using. If it's more than 150 MiB or so, it's worth trying this tweak.

I still need more memory, but at least I can leave my browser open when I do other things now.

No comments:

Post a Comment