Firefox Gets Memory Improvements

Memory usage has always been the Achilles’ heel of the Firefox browser for part of the user base. Mozilla acknowledges that and is currently working on optimizing the browser’s memory usage significantly.
One would normally assume that opening a tab increases memory usage, and that closing the same tab would drop memory utilization again to levels prior to opening that tab. That assumption up until now has not been true, which can be attributed largely to JavaScript
fragmentation.

Firefox allocates 1 Megabyte chunks for the browser’s JavaScript heap. These chunks are returned once they are completely empty of data that is used by the browser. The only problem until now was that chunks contained objects and elements from various processes, sites and browser features.

Gregor Wagner analyzed the behavior and noticed that about 30% of the 1 Megabyte chunks could not be deleted because of small files that were still in use in the chunks.
Wagner implemented a patch that separated long and short lived objects by “placing system and user objects into separate chunks”. He defines long lived objects as browser elements that do not come from web pages. The core benefit of this approach is that chunks can be emptied a lot quicker which means that they can be returned to the operating system.
An improvement of about 30% was noticed on average on patched versions of the firefox web browser.
Closing all tabs after surfing:
  • 108,003,328 B — js-gc-heap (without patch)
  • 20,971,520 B — js-gc-heap (with patch)
Memory footprint of the whole browser:
  • 310,890,496 B — resident (without patch)
  • 219,856,896 B — resident (with patch)
That’s an impressive improvement which will likely make its way into the upcoming Firefox 7 browser.
Nicholas Nethercote posted a summary of Firefox memory improvements on his Mozilla based blog which includes information about George Wagner’s optmizations, but also information about other parts of the browser that get optimized.
Firefox users can look forward to the next but one version of the browser that ships with all those improvements. In related news, the first Firefox 8 Nightlies have been spotted on the Mozilla server.

No comments:

Post a Comment