Thursday, November 01, 2007

Firefox memory leak

I am a big fan of Firefox, in fact i use IE just for LiveMeeting, Siebel on Demand and the outlook webmail. I haven't even bothered upgrading to IE 7. As for Firefox i use it so extensively that i keep a browser window alive for days together. I have a peculiar habit, whenever i come across a good link i open it in a new tab and keep it open till i am done reading it. This overtime causes my browser to hold 10-20 tabs and i have to use the 'hibernation' feature in WinXP to preserve it.

Firefox starts quite smartly with a minimal memory consumption of 40-50 mb but as you open more tabs and persist them for a couple of days it grows at a healthy rate often, in my case, reaching levels of 1 GB. This was a big disappointment for me. Win XP if not shutdown at regular intervals gets slower and suffers distinctly noticeable performance degradation. By not shutting down my laptop for a few days i was already making my laptop slower but now i also had to deal with the growing memory consumption of Firefox. With a little investigation i came across this article which explains the reason for this memory surge.

The article does make a lot of sense and now i understand the reason for the memory surge, in fact i changed the value of browser.sessionhistory.max_total_viewers from -1 to 3 and the memory utilization hasn't crossed 125MB since. This feature for me falls into the bracket of 'self-destructing' features. They have a typical life-cycle, it starts of with a good idea and noble intentions but then when it actually gets in the hands of real customers it just explodes in their face. I remember this firefox plugin which came out a few years ago called 'fasterfox'. It was designed simply to improve page loading which was achieved by pre-fetching links and specific content types like html, pictures, etc. Initially it received a lot of attention from all reviewers and it featured in the "top 10 plugins for firefox" articles but soon people realized the impact of this plugin as it started bringing down servers due to aggressive prefetching beyond specifications. Eventually a year later from its introduction fasterfox was featured in the worst firefox plugin articles. (A side effect of this plugin was that it scared the hell out of all IT departments and to date many of them in large companies do not support or allow the use of firefox).

The "Back-Forward cache" feature also falls in the same bucket as fasterfox. Its a very useful feature and if used in a controlled manner can be quite effective but by setting this cache size to an unrealistic '8' and allowing firefox to consume as much as 4 GB of memory, the firefox developers have shot themselves in the foot. Now, besides the many useful and cool features of firefox the most discussed topic is its memory leak. Instead had they started off by setting the cache size to an optimal level nobody would have ever run into this issue, in fact only advanced users would have ever bothered to customize this value.

This said firefox does have some genuine memory utilization issues e.g. if you open 10 tabs the memory utilization shoots up but when you close these tabs the memory is not released completely until you restart the browser window. I guess this is some bug with their garbage collection. Firefox is no way perfect but still they could have made their life a little easier by not introducing these 'self-destructing' features.

Despite all these problems i still love Firefox and nothing in this world would make me switch to any other browser, Safari included. :)

Powered by ScribeFire.