Mozilla Firefox Gets Major Memory Improvements - gHacks Tech News

Mozilla Firefox Gets Major 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.





  • We need your help

    Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

    We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.

    If you like our content, and would like to help, please consider making a contribution:

    Comments

    1. anaklein said on July 7, 2011 at 12:19 pm
      Reply

      thats was very needed

    2. Mehdi S said on July 7, 2011 at 12:19 pm
      Reply

      The Toms Hardware WBGP 5 is out….Firefox cannot still compete with IE and Chrome in terms of memory management. It gets totally destroyed…
      Link below

      http://www.tomshardware.com/reviews/opera-firefox-chrome,2976-10.html

      1. pd said on July 9, 2011 at 5:02 pm
        Reply

        What are you talking about? That site has Firefox second best when it comes to memory use for 40 tabs:

        http://media.bestofmicro.com/K/T/298829/original/memuse40tabswbgp5.png

    3. Paul(us) said on July 7, 2011 at 12:24 pm
      Reply

      Really great news, Do you think that the add-on memory fox (and look a likes) are still needed, to let the memory consumption go down quickly?

      1. Martin Brinkmann said on July 7, 2011 at 12:54 pm
        Reply

        I’d say they become less effective.

        1. nick said on July 7, 2011 at 9:26 pm
          Reply

          Is this a typo: Firefox users can look forward to the next but one version of the browser that ships with all those improvements.

          I don’t understand “forward to the next but one version”

    4. JohnBoy said on July 7, 2011 at 1:23 pm
      Reply

      “Firefox users can look forward to the next but one version of the browser that ships with all those improvements”

      i don’t understand what this says. Please elaborate

      1. Martin Brinkmann said on July 7, 2011 at 1:24 pm
        Reply

        Will not be available in Firefox 6, but in Firefox 7.

        1. pd said on July 9, 2011 at 4:58 pm
          Reply

          You can always try Aurora 70.0a2 which Nicholas Nethercote confirms is the first semi-stable release to get this new memory management code:

          http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-aurora/

    5. Antonio said on July 7, 2011 at 1:47 pm
      Reply

      This is only a part of the problem. The ram usage increases endlessly even if I do not open any tab. It increases even if I do nothing at all.

      1. Phillip said on July 7, 2011 at 3:13 pm
        Reply

        Antonio
        Sounds like its an addon problem. At home I use 25-35 tabs 24/7 and only restart firefox about once a week when I reboot and it generally stays between 550-650MB of ram.

        1. boris said on July 8, 2011 at 2:03 am
          Reply

          That is too much RAM for normal use. My Firefox slows to crawl above 600MB Ram. Thankfully I stay under 12 tabs and do not have to restart Firefox more than once a day(on normal day)

        2. pd said on July 9, 2011 at 4:55 pm
          Reply

          Unfortunately Nicholas Nethercote says that disclosing Add-On memory usage is something that they really have no idea how to do:

          “measuring add-on memory consumption is hard, unfortunately. Firefox lets add-ons hook their claws in so deeply it’s difficult to know where Firefox ends and the add-on starts. I wish I knew a way to do it, because it would render the “are you running add-ons? have you disabled them?” routine moot.”

        3. Martin Brinkmann said on July 9, 2011 at 5:19 pm
          Reply

          How about some tests with the add-on enabled and disabled to find out?

    6. Gabo Lugo said on July 7, 2011 at 9:27 pm
      Reply

      About time.

    7. tbvnz said on July 10, 2011 at 3:36 pm
      Reply

      I use Firefox 3.6 with 40+ addons along with Stylish(40+ user styles). I’ve
      been using the Minimem memory management application by Kerkia and use
      around 80k – 150k with 10 tabs open and around 15k – 30k with 1 or 2 open.

    Leave a Reply