mozilla

Revision 38242 of Zombie compartments

  • Revision slug: Zombie_compartments
  • Revision title: Zombie compartments
  • Revision id: 38242
  • Created:
  • Creator: nnethercote
  • Is current revision? No
  • Comment page created, 533 words added

Revision Content

Firefox’s JavaScript memory is segregated into compartments.  Roughly speaking, all memory used by JavaScript code that is from a particular origin (i.e. website) goes into its own compartment.  Firefox’s own JavaScript code also gets one or more compartments.  Compartments improve security and memory locality.

If you want to see the memory usage for each compartment, you can do so by visiting in about:memory?verbose and looking in the "Explicit Allocations" tree at the top.  (Nb: The "?verbose" part is important;  if you omit that then parts of the "Explicit Allocations" tree will be hidden and you won't see measurements for all compartments.)  Each compartment gets a subtree that is headed with

 

 

Per-compartment memory reporters allow you to look at about:memory to see what compartments are present.  Once you close a tab containing a web page, all the compartments associated with that web page should disappear.  (But note that they won’t necessarily disappear immediately;  garbage collection and/or cycle collection has to run first.)

Sometimes this doesn’t happen and you end up with a Zombie Compartment.  This shouldn’t happen, and it indicates a bug.  It also makes children and 1950s B-movie actresses scream.

 

If you notice Zombie Compartments while browsing, please report them to The Authorities.  Here are some steps you can follow when reporting one that will increase the chance it’ll be hunted down.

  • First, you should use about:memory?verbose for diagnosis.  You want the “?verbose” suffix (which you can also get to by clicking the “More verbose” link at the bottom of about:memory) otherwise small compartments might be omitted.
  • Second, beware that many sites utilize scripts from other origins.  Scripts from Google, Facebook and Twitter are particularly common. This means that the most reliable diagnosis of a Zombie Compartment occurs if you do the following: start Firefox anew, open about:memory?verbose and one other tab, then close that other tab, then hit “minimize memory usage” at the bottom of about:memory?verbose several times to force multiple garbage and cycle collections.  (Sometimes hitting it once isn’t enough, I’m not sure why.)  If the compartment remains, it’s very likely a Zombie Compartment.
  • After that, try waiting a while, say 10 or 20 minutes, then try the “minimize memory usage” button again.  Some Zombie Compartments stick around for a limited time before disappearing;  others are immortal, and it’s useful to know which is which.
  • Some Zombie Compartments are caused by add-ons.  So if you have add-ons enabled, please try to reproduce in safe mode, which disables them.  If you can identify, by disabling them one at a time, a single add-on that is responsible, that is extremely helpful.  Zombie compartments that are caused by add-ons are definitely interesting, but their importance depends on the popularity of the add-on.
  • Finally, please file a bug that includes all the information you’ve gathered, add “[MemShrink]” to its whiteboard, and mark it as blocking bug 668871.  Attaching the full contents of about:memory?verbose is very helpful.  See bug 669545 for an example.

Please, stop the screaming.  Report Zombie Compartments to The Authorities.

Revision Source

<p>Firefox’s JavaScript memory is segregated into <em><a class=" external" href="http://andreasgal.com/2010/10/13/compartments/">compartments</a></em>.  Roughly speaking, all memory used by JavaScript code that is from a particular origin (i.e. website) goes into its own compartment.  Firefox’s own JavaScript code also gets one or more compartments.  Compartments improve security and memory locality.</p>
<p>If you want to see the memory usage for each compartment, you can do so by visiting in <a href="/about:memory" title="about:memory">about:memory</a><a href="/about:memory?verbose" title="about:memory?verbose">?verbose</a> and looking in the "Explicit Allocations" tree at the top.  (Nb: The "?verbose" part is important;  if you omit that then parts of the "Explicit Allocations" tree will be hidden and you won't see measurements for all compartments.)  Each compartment gets a subtree that is headed with</p>
<p> </p>
<p> </p>
<p><a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=661474">Per-compartment memory reporters</a> allow you to look at <a>about:memory</a> to see what compartments are present.  Once you close a tab containing a web page, all the compartments associated with that web page should disappear.  (But note that they won’t necessarily disappear immediately;  garbage collection and/or cycle collection has to run first.)</p>
<p>Sometimes this doesn’t happen and you end up with a <em><a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=668871">Zombie Compartment</a></em>.  This shouldn’t happen, and it indicates a bug.  It also makes children and 1950s B-movie actresses scream.</p>
<p style="text-align: center;"> </p>
<p>If you notice Zombie Compartments while browsing, please report them to <a class=" link-https" href="https://wiki.mozilla.org/Performance/MemShrink">The Authorities</a>.  Here are some steps you can follow when reporting one that will increase the chance it’ll be hunted down.</p>
<ul> <li>First, you should use <a>about:memory?verbose</a> for diagnosis.  You want the “?verbose” suffix (which you can also get to by clicking the “More verbose” link at the bottom of <a>about:memory</a>) otherwise small compartments might be omitted.</li> <li>Second, beware that many sites utilize scripts from other origins.  Scripts from Google, Facebook and Twitter are particularly common. This means that the most reliable diagnosis of a Zombie Compartment occurs if you do the following: start Firefox anew, open <a>about:memory?verbose</a> and one other tab, then close that other tab, then hit “minimize memory usage” at the bottom of <a>about:memory?verbose</a> several times to force multiple garbage and cycle collections.  (Sometimes hitting it once isn’t enough, I’m not sure why.)  If the compartment remains, it’s very likely a Zombie Compartment.</li> <li>After that, try waiting a while, say 10 or 20 minutes, then try the “minimize memory usage” button again.  Some Zombie Compartments stick around for a <a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=671053">limited time</a> before disappearing;  others are <a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=669730">immortal</a>, and it’s useful to know which is which.</li> <li>Some Zombie Compartments are <a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=672619">caused by</a> add-ons.  So if you have add-ons enabled, please try to reproduce in <a class=" external" href="http://support.mozilla.com/en-US/kb/Safe%20Mode">safe mode</a>, which disables them.  If you can identify, by disabling them one at a time, a single add-on that is responsible, that is extremely helpful.  Zombie compartments that are caused by add-ons are definitely interesting, but their importance depends on the popularity of the add-on.</li> <li>Finally, please file a bug that includes all the information you’ve gathered, add “[MemShrink]” to its whiteboard, and mark it as blocking <a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=668871">bug 668871</a>.  Attaching the full contents of <a>about:memory?verbose</a> is very helpful.  See <a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=669545">bug 669545</a> for an example.</li>
</ul>
<p>Please, stop the screaming.  Report Zombie Compartments to The Authorities.</p>
Revert to this revision