Fragmentation

After fixing a very annoying GC trigger problem I noticed that our heap doesn’t shrink to its original size. During startup we usually have 20 – 30MB in our JavaScript heap. After random surfing I noticed that it doesn’t go back even if I close all tabs and trigger the GC many times. The heap size stays at about 100MB. There are two possible reasons for that: 1) leaks and 2) fragmentation.

We allocate 1MB chunks from the OS and once they are completely empty, we can return them to the OS. Our problem was that we allocate all sort of objects in these chunks and we didn’t use obvious life-time information during allocation. A short profiling showed that after random surfing we end up in a situation where 30% of our 1MB chunks are only alive because on arena or 4KB are used. That’s terrible!

I implemented a patch that separates long and short-lived objects by just placing system and user objects into separate chunks. Long lived objects are all system objects that are created by the browser and not from a web-page and all immutable strings that are shared across the whole JavaScript VM. The main advantage of the patch is that single long-lived objects don’t keep whole 1MB chunks alive and we can return empty chunks to the OS much quicker.

The outcome was amazing! Measurements show that we reduce the memory footprint of the JavaScript heap by 30% on average during regular surfing and 500% if we close all tabs after surfing. In numbers…

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)

WOW a major improvement for all Firefox users that is already in the nightly and aurora builds. It will be shipped with the Firefox 7 release for everybody!

This entry was posted in Firefox GC. Bookmark the permalink.

10 Responses to Fragmentation

  1. Pingback: Speicherverbrauch von Firefox deutlich reduziert | Thomas Joss

  2. Josh says:

    This is absolutely fantastic news! Thank you so much for your valiant efforts to improve the performance of Firefox’s resource consumption. Too often, developers use the excuse “modern machines are so powerful it doesnt matter”. It does matter!

  3. Pingback: Firefox 7 Aurora: Download & Release Notes - Sören Hentzschel

  4. Jason says:

    I’d like to reiterate Josh’s comments. It’s good to see this kind of attention to detail finally happening on the Firefox project.

  5. rea says:

    If you want to grow your experience just keep visiting this web site and be updated with the hottest news update
    posted here.

  6. Merry says:

    I see you share interesting stuff here, you can earn some
    extra cash, your website has big potential, for the monetizing
    method, just search in google – K2 advices how to monetize
    a website

  7. I loved as much as you will receive carried out right
    here. The sketch is tasteful, your authored material stylish.
    nonetheless, you command get bought an shakiness over that you wish be
    delivering the following. unwell unquestionably come more formerly
    again since exactly the same nearly a lot often inside case you shield this
    hike.

    Feel free to visit my web site :: למד אינטרנט נוסף

  8. Hello there! This article couldn’t be written any better!

    Looking at this post reminds me of my previous roommate!
    He continually kept talking about this. I most certainly will forward this post to him.

    Pretty sure he will have a great read. Thank you for sharing!

    my web site: מנעולן 24 שעות בחיפה

  9. I really like what you guys are usually up too. This type of clever work and coverage!

    Keep up the good works guys I’ve included you guys to blogroll.

    my weblog; קידום אתרים כובע לבן

  10. This excellent website definitely has all of the information I needed concerning
    this subject and didn’t know who to ask.

    Here is my web site :: מנעולן זול באזור חיפה

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>