Breakthrough: Mozilla To Eliminate Add-on Memory Leaks
When it comes to the Firefox web browser, add-ons are without doubt one of the most important feature that are making the browser attractive to a lot of users. It is in fact still a feature that is setting the browser apart from other web browsers, be it Opera or Chrome. Add-ons can however also cause issues for users of the browser, especially when it comes to memory leaks. This in fact may be one of the reasons why users see the browser's memory use grow over time on the operating system.
To make matters worse, Firefox is still seen by many as the browser with the worst memory management, even though that is not really the case, if you level the playing field. Depending on the add-ons installed, and versions of the browser used, results may vary.
Mozilla very recently made a breakthrough that has not yet been picked up by any tech news site out there.Â In fixing the memory leak, Mozilla developer Kyle Huey explains how he fixed add-on memory leaks once and for all in the web browser.
My approach takes advantage of the fact that chrome code lives in a separate compartment from web page code.Â This means that every reference from chrome code to content code goes through a cross-compartment wrapper, which we maintain in a list.Â When the page is navigated, or a tab is closed, we reach into chrome compartment and grab this list.Â We go through this list and â€œcutâ€ all of the wrappers that point to objects in the page weâ€™re getting rid of.Â The garbage collector can then reclaim the memory used by the page that is now gone.
In layman terms, Firefox is now blocking add-ons from accessing content in the browser that does not exist anymore.
Memory usage over time of a specifically prepared test suite has dropped by 80%. Instead of climbing up to 800 or 900 Megabytes at the end of the day, Firefox would now use about 230 Megabytes instead. Even on systems with lots of memory, users will still see benefits due to garbage collection and cycle collection pauses.
However, what if the user has a high-end machine with 16GB of RAM?Â Then paging isnâ€™t an issue.Â But this improvement will still be a big deal on such a machine.Â This is because garbage collection and cycle collection cause pauses, and the length of the pauses are roughly proportional to the amount of live heap memory.Â (Incremental garbage collection will soon be enabled, which will result in smaller garbage collection pauses, but there are no plans for incremental cycle collection and so cycle collection pauses will still be relevant.)Â So even on high-end machines with lots of RAM, leaks can greatly hurt browser performance.
There is however still one issue that Mozilla needs to get their heads around. The patch managed to prevent the single most common class of add-on leaks, but has caused another leak to come forward that is caused by add-ons that have been compiled with an older version of the Add-on SDK. It may take some time before that issue is resolved by the developers, but once that is resolved, you can wave goodbye to add-on memory leaks.
Firefox users who want to try a version of the browser with the feature enabled, can download one of the latest Nightly builds from Mozilla to do so. These are cutting edge development builds, and not suitable for productive environments.Â If things go along as planned, we will see the feature as early as in Firefox 15 which is scheduled for an August 28, 2012 release.
Fixing add-on memory leaks is an important step for Mozilla, as it not only will make the browser faster for a lot of users, it will also change the perception that users have when they use it. Things are looking a lot brighter now. (thanks Adam for the tip)Advertisement
About time – for me memory leaks are the only serious defect in this great browser. Well, besides the new and crazy 24 hour update cycle…
Yes! This is it! I love you Mozilla :D
Great news. Now if they’ll just quit trying to look like Chrome…
Finally the developers changed something that actually needed change!!!
That’s something to talk about. That’s what developers should highlight.
Great news for those who leave they’re browser open all day?? For those that open and close their browser regularly memory leaks really aren’t an issue.
Moving devs to a newer SDK should be manageable. A simple notice prior to the next release or the add-on falls victim to being labeled incompatible.
My wish list for Firefox is a tight sandbox like Chromium and a mandatory Low Integrity level. Then again, I don’t run as an Admin so it’s not a huge deal for me.
I’m skeptic, so first I want to see how it works in stable build ;)
That sounds great!
I can’t wait to test it, I have been using firefox since the 0.x phoenix days and there have been some really great highs come from mozilla but over the past few years there has been a lot of lows whilst firefox has become more robust and the scope of web development has escalated quite a bit since firefox has saidly become more and more sluggish in respect to memory management and stability so much so that at this point I am using opera and I must say my net enjoyment seems sacrificed on this thing, I have also looked to chrome (chrome plus, and SW Iron) for a different experience and something to fill the void temporarily until firefox becomes stable again.
What I would like to see is some form of task manager similar to chrome that can somewhat benchmark addons, extensions and allow you to gather statistics from each tab and trace down leaks and problems in a more efficient manner therefore every layman can min/max their browser to perform at its optimum.
I agree, it would be really cool to see how individual add-ons, themes and the like perform, for instance to spot add-ons that use to much bandwidth or cpu.
MemShrink & Snappy have again brought Firefox to a level where it is enjoyable to use.
Can’t wait for SuperSnappy and Electrolysis tho