{"id":1936,"date":"2012-05-16T17:26:55","date_gmt":"2012-05-16T06:26:55","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=1936"},"modified":"2012-05-16T17:26:55","modified_gmt":"2012-05-16T06:26:55","slug":"memshrink-progress-week-47-48","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2012\/05\/16\/memshrink-progress-week-47-48\/","title":{"rendered":"MemShrink progress, week 47&#8211;48"},"content":{"rendered":"<h3>Add-ons<\/h3>\n<p>The main news in the past two weeks has been about Kyle Huey&#8217;s patch that prevents most chrome-to-content leaks, which are the most common kind of add-on leak.\u00a0 Testing showed it <a href=\"http:\/\/blog.mozilla.org\/nnethercote\/2012\/05\/07\/update-on-leaky-add-ons\/\">worked beautifully, but caused a knock-on leak in add-ons built with old versions (1.3 and earlier) of the Add-on SDK<\/a>.\u00a0 <a href=\"http:\/\/news.ycombinator.com\/item?id=3942942\">(This<\/a> <a href=\"http:\/\/www.webmonkey.com\/2012\/05\/mozilla-shrinks-memory-use-in-firefox-add-ons\/\">received<\/a> <a href=\"http:\/\/news.softpedia.com\/news\/Firefox-Fixes-Big-Add-on-Memory-Leak-Inadvertently-Uncovers-Another-268326.shtml\">a<\/a> <a href=\"http:\/\/www.zdnet.co.uk\/blogs\/security-bulletin-10000166\/mozilla-patches-leaky-add-ons-issue-10026114\/\">lot<\/a> <a href=\"http:\/\/www.webpronews.com\/firefox-memory-leaks-somewhat-fixed-with-patch-2012-05\">of<\/a> <a href=\"http:\/\/thenextweb.com\/apps\/2012\/05\/08\/upcoming-firefox-update-to-fix-add-on-bloat-reduce-memory-consumption-by-up-to-four-times\/\">attention<\/a>.)\u00a0 Kyle then made a <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=752877\">slight tweak<\/a> that <a href=\"http:\/\/blog.mozilla.org\/nnethercote\/2012\/05\/15\/additional-update-on-leaky-add-ons\/\">fixed that knock-on leak<\/a>.\u00a0 So we&#8217;re currently still on track for Firefox 15 being &#8220;the one that fixes add-on leaks&#8221;.<\/p>\n<p>For completeness, here are the add-ons that we know were temporarily affected by that knock-on leak:\u00a0 <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=751420\">Wallflower<\/a>, <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=752468\">Visual Hashing<\/a>, <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=752497\">Translate This!<\/a>, <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=752500\">Easy YouTube Video Downloader<\/a>.\u00a0 They (and probably quite a few others) are all working fine again now.<\/p>\n<p>Here&#8217;s a quote from an email that one user sent to Kyle this week.<\/p>\n<blockquote><p>Firefox was leaking about 1.5GB per hour for me. It started with Firefox 3. I tracked it down to Ghostery and NoScript, but even without those addons it leaked about 500MB per hour of browsing.<\/p>\n<p>GC and CC times got up into the 10 second range. Ugly. Really really ugly! And this is on top of the line massively overclocked hardware, too. I had to install a new addon to add a restart button to Firefox, because Firefox froze solid after hitting 2GB of memory usage. I also patched it after every update to allow up to 4GB, buying a little more time&#8230;<\/p>\n<p>Then your patch comes along and solves it all&#8230; you are awesome man &#8211; totally awesome!<\/p><\/blockquote>\n<p>Another user &#8212; one who uses the <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=732782\">leaky Autopager add-on<\/a> &#8212; <a href=\"http:\/\/blog.kylehuey.com\/post\/21892343371\/fixing-the-memory-leak#comment-524693082\">commented<\/a> on Kyle&#8217;s blog.<\/p>\n<blockquote><p>Certainly, before this fix I would find that Firefox often became sluggish (input lag, slow paint operations, less than silky smooth scroll animations) as the memory usage built up. It&#8217;s hard to say how much various factors contributed to the whole, but GC pauses did undoubtedly cause the scroll animation stuttering.<\/p>\n<p>Restarting was the cure. I haven&#8217;t noticed the same symptoms since, and while I haven&#8217;t had enough chance to make a conclusive judgement, the signs certainly seem to be good.<\/p>\n<p>I have a full tab strip more often than not, and Fx set to load tabs from last time. This is offset by the wonderful and elegantly simple tabs on demand feature. I&#8217;m running a 2 year old laptop with 4GB ram.<\/p><\/blockquote>\n<p>And while we&#8217;re on the topic, here&#8217;s a <a href=\"https:\/\/blog.mozilla.org\/nnethercote\/2012\/05\/15\/additional-update-on-leaky-add-ons\/#comment-6317\">comment<\/a> from my blog.<\/p>\n<blockquote><p>Opened my firefox today, 30+ Tabs (only counting the ones in the active group, the others aren&#8217;t loaded), using just little more than 330 MB of RAM. A year ago, with Firefox 4, this would have been impossible. Keep it going!<\/p><\/blockquote>\n<p>Good times.<\/p>\n<p>The following add-ons had zombie compartments fixed:\u00a0 <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=742232\">Youtube Ratings Preview<\/a>, <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=739803\">SPDY Indicator<\/a>\u00a0 It&#8217;s likely these leaks would have been fixed by Kyle&#8217;s change, but since Firefox 15 won&#8217;t be released until August 28, it&#8217;s good that they&#8217;ve been fixed now.\u00a0 (Indeed, the AMO review policy still requires that add-ons not cause zombie compartments with the current release of Firefox;\u00a0 that policy may be revisited once Firefox 15 is released.)<\/p>\n<h3>Compartment-per-global<\/h3>\n<p>The other big news is that <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=650353\">compartment-per-global<\/a> (CPG) landed, thanks to the work of various people, especially Luke Wagner and Bobby Holley.\u00a0 Bobby <a href=\"http:\/\/bholley.wordpress.com\/2012\/05\/04\/at-long-last-compartment-per-global\/\">explained what this means and explored some of the consequences<\/a>.<\/p>\n<p>CPG will allow lots of things within Firefox to become simpler and faster.\u00a0 The main disadvantage is, unfortunately, increased memory consumption, as can be seen on <a title=\"Browser flavours\" href=\"http:\/\/areweslimyet.com\/\">areweslimyet.com<\/a>.\u00a0 (Thanks to Luke, this increase <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=720753\">was less than it could have been<\/a>.)\u00a0 This is mostly due to more fragmentation in the JavaScript heap &#8212; we now have many more compartments, and each 4KB heap arena cannot be shared between compartments, so there are many more partially empty arenas present.<\/p>\n<p>You might think this would make me bang my head against the wall in frustration, but it doesn&#8217;t.\u00a0 That&#8217;s because even if I ignore the many non-MemShrink-related benefits of CPG, there are two big MemShrink-related ones.<\/p>\n<p>First, CPG will enable <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=687724\">per-tab memory reporting<\/a>, something that users have been requesting for years.<\/p>\n<p>Second, CPG will lead to much more detail in about:memory and about:compartments.\u00a0 For example, Nils Maier has <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=754771\">written a patch<\/a> that makes it obvious <a href=\"http:\/\/pastebin.mozilla.org\/1637716\">all the JavaScript modules that have been loaded<\/a>.\u00a0 Another example:\u00a0 Justin Dolske found that plusone.google.com was doing something silly (constantly creating new iframes?) that caused <a href=\"https:\/\/twitter.com\/#!\/dolske\/status\/200787837275213825\">huge numbers of compartments to be created<\/a>;\u00a0 without CPG I think all those globals would have been lumped into a single compartment and the problem would have been much less obvious.\u00a0 More information in about:memory will lead to more diagnosis of existing problems &#8212; particularly leaks of various kinds &#8212; in both Firefox and websites.<\/p>\n<h3>Memory Reporting<\/h3>\n<p>Kevin Locke <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=752357\">tweaked the JS memory reporters so that more compartments are distinguished, instead of being lumped together<\/a>.\u00a0 This was his first Mozilla patch &#8212; well done, Kevin!<\/p>\n<p>Nathan Froyd <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=747508\">improved the coverage of the layout memory reporters<\/a>.\u00a0 This significantly reduces &#8220;heap-unclassified&#8221; for huge pages like the <a href=\"http:\/\/www.whatwg.org\/specs\/web-apps\/current-work\/\">single-page version of the HTML5 spec<\/a>.<\/p>\n<h3>Bug counts<\/h3>\n<p>Here are the current bug counts.<\/p>\n<ul>\n<li>P1: 22 (-2\/+3)<\/li>\n<li>P2: 83 (-6\/+4)<\/li>\n<li>P3: 105 (-5\/+6)<\/li>\n<li>Unprioritized: 3 (-1\/+3)<\/li>\n<\/ul>\n<p>Mostly bouncing around at the moment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add-ons The main news in the past two weeks has been about Kyle Huey&#8217;s patch that prevents most chrome-to-content leaks, which are the most common kind of add-on leak.\u00a0 Testing showed it worked beautifully, but caused a knock-on leak in add-ons built with old versions (1.3 and earlier) of the Add-on SDK.\u00a0 (This received a [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119,30,4544,4546],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/1936"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/comments?post=1936"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/1936\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=1936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=1936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=1936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}