Friday, January 29, 2010

Reduce firefox memory usage

Firefox has been gaining popularity by the day and it holds a considerable market share when it comes to the battle of the browsers. They key to Firefox's popularity is its speed, security, ease of use, and of course the ever useful add-ons. While Firefox has made tremendous improvements in terms of features, security and speed, it has repeatedly failed in addressing a major issue, that of memory leak.

I have been a fan of Firefox for past many years. I had read it in some computer magazine that a new browser called Firefox was an upcoming hero and I wanted to try it. Once I tried, I never left. Firefox has got many features that suit my taste. But for past many months I have been noticing that after a long period of time, Firefox starts using up a lot of memory. If I am surfing on my desktop computer then I do not notice the difference much because it has got 2 GB of ram. But my laptop with 1 GB of ram starts lagging after around 2-3 hours of continuous surfing. I understand I end up opening too many tabs and that may have slowed it down but after closing the tabs at least it should be working fine with reduced memory consumption, but that wasn't happening.

The next thing I tried was that I opened up some 4-5 tabs and kept Firefox open all night long and went to bed. When I got up in the morning it was consuming around 750 MB out of 1GB ram and when I tried surfing, it was lagging. This condition, I came to know, was a consistent problem in Firefox and is known as 'memory leak'. Click the image to see a larger one.

According to Wikipedia, "a memory leak or leakage in computer science is a particular type of memory consumption by a computer program where the program is unable to release memory it has acquired. A memory leak has symptoms similar to a number of other problems (see below) and generally can only be diagnosed by a programmer with access to the program source code; however, many people refer to any unwanted increase in memory usage as a memory leak, even if this is not strictly accurate."

In layman's terms and in our context, Firefox is using up memory, i.e. ram, to do its work. After that particular work is finished, it should release that bit of ram. But here is out problem. Firefox is unable to release that bit of ram and there after a period of time this unreleased ram causes the Firefox to bloat and make the computer slow. With recent releases, Firefox has been trying to solve this problem and thought it has become less prominent than before, people who are browsing for long hours will still feel this issue.

So how can we stop Firefox from hogging the memory and making our computer slow ? Well, I read up a lot on this topic and discussed with some programmers and from what I have understood, it's a problem that we really can't 'stop'. It's upto Mozilla's programmers who will do it. All we can do is to tweak the settings and make this condition improve. I have eventually come across some Firefox tweaks that will eventually help reduce the memory consumption of Firefox a lot. I have used the method and my browsing experience has really improved a lot. Here's what you need to do.

1) Uninstall or atleast disable the add-ons that you are not currently using. Keep only those that are needed. These add-ons use a considerable amount of memory. Though this isn't a major issue.
2) The main thing is to follow the set of instructions given below. They are the ones that will show drastic improvements.

Firefox has a hidden configurations option 'about:config' that can be tweaked to obtain better results and we are going to use that to solve our memory problem.

Get the main configuration screen by putting 'about:config' in the browser’s address bar.
  1. It will display a warning window. Just click on 'I'll be careful I promise' button and proceed.
  2. On the filter bar on the top, type 'browser.cache.memory.capacity'. Below in the empty space, right click and select New, then put 'browser.cache.memory.capacity' in the preference name and set it to a low number. Most people prescribe the number 16384 for the value which is 15 MB in size. This tweak controls how many kilobytes of memory are used for the browser's cache.
  3. Now again in the filter, put 'browser.cache.disk.capacity'. In the space below you will notice an entry. Right click on that and select Modify, then put a number 5000(if u have 128-512MB of ram) else use 15000. This tweak controls how many kilobytes of memory are used for the browser's cache.
  4. Again in the filter, type 'config.trim_on_minimize'. In the empty space below, right click and select New then Boolean and put preference name as 'config.trim_on_minimize' and set it to True. This tweak actually makes Firefox swap the memory to disk when it is minimized. That is, it will free up memory from the ram and store it temporarily onto the hard disk when it is minimized. Thus you will notice a large fall in memory when you minimize the browser.
  5. In the filter again, put 'network.prefetch-next', set this Boolean setting to False by modifying it. This setting will stop prefetching of data from sites. Prefetching is often unnecessary and stopping this frees up memory and improves speed.
  6. In the filter space again, put 'browser.sessionhistory.max_total_viewers'. This setting implies the number of pages to be saved in memory for going back using the Back/Forward buttons. Generally we do not need much so setting it at 5 or 8 is enough for most people.
Restart Firefox and now your computer will be much faster than it was before.

Note: the information on this page has been gathered from all over the internet and then compiled.

4 comments:

Goyal's era said...

Nice info optimystix

optimystix said...

am happy you liked it Goyal

Sachin Khatodiya said...

Thanks Dude....
Really Good One...

optimystix said...

thanks sachin. it would be nice if you could post the results of your implementation here for everyone here too see.

Post a Comment

Please post your comments on whether you liked it and what else would you like me to write on. Suggestions of all types are welcome.