{"id":694,"date":"2011-05-06T11:13:14","date_gmt":"2011-05-06T00:13:14","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=694"},"modified":"2011-05-06T11:13:14","modified_gmt":"2011-05-06T00:13:14","slug":"another-leak-fixed-part-2","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2011\/05\/06\/another-leak-fixed-part-2\/","title":{"rendered":"Another leak fixed, part 2"},"content":{"rendered":"<p>I recently <a href=\"http:\/\/blog.mozilla.org\/nnethercote\/2011\/05\/04\/another-leak-fixed\/\">wrote<\/a> about <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=654106\">bug\u00a0654106,<\/a> a memory leak that has been fixed.\u00a0 In <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=653817\">bug\u00a0653817<\/a> the reporter made some measurements that show this leak was quite a bad one.\u00a0 The reporter measured &#8220;Uss&#8221; using procrank on an Android device.\u00a0 <a href=\"http:\/\/elinux.org\/Android_Memory_Usage\">This page<\/a> says:<\/p>\n<blockquote><p>&#8220;Uss is the set of pages that are unique to a process.  This is the  amount of memory that would be freed if the application was terminated  right now.&#8221;<\/p><\/blockquote>\n<p><a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=653817#c19\">Comment 19<\/a> and <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=653817#c24\">comment 24<\/a> have the numbers before and after the leak was fixed.\u00a0 The reporter opened Firefox (with a single tab containing about:memory), measured the memory usage, then opened 8 popular sites, re-measured several times, then closed them all (except about:memory), re-measured, then re-opened them, and so on through several cycles.\u00a0 The following table shows the key measurements from the first cycle.<\/p>\n<table border=\"1\" cellpadding=\"3\" width=\"388\" height=\"77\">\n<tbody>\n<tr>\n<th><\/th>\n<th>Before<\/th>\n<th>After<\/th>\n<\/tr>\n<tr>\n<td>Start-up<\/td>\n<td>47,972 KiB<\/td>\n<td>48,700 KiB<\/td>\n<\/tr>\n<tr>\n<td>Open 8 tabs, wait 90 minutes<\/td>\n<td>251,844 KiB<\/td>\n<td>240,064 KiB<\/td>\n<\/tr>\n<tr>\n<td>Close 8 tabs<\/td>\n<td><span style=\"color: #ff0000;\">226,328 KiB<\/span><\/td>\n<td><span style=\"color: #ff0000;\">108,908 KiB<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>These measurements have some noise, so don&#8217;t read too much into the minor differences.\u00a0 The important difference is the last row;\u00a0 the Uss after closing the 8 content tabs was 2.1x smaller after fixing the leak!<\/p>\n<p>So, this is a great leak to have fixed.\u00a0 But I have several concerns remaining.<\/p>\n<ul>\n<li>It&#8217;s worrying that such a bad leak was able to get into Firefox 4.0 and remain undetected for this long.\u00a0 My understanding is that we have various kinds of automatic leak detection tools, but I don&#8217;t know much about them, why they might not have detected this, and whether they could be improved.<\/li>\n<li>The Uss after closing the 8 tabs is 2.2x higher than at start-up.\u00a0 That seems high.\u00a0 One thing I&#8217;ve been trying to understand lately is what kind of memory usage can legitimately remain when a lot of tabs have been closed and there&#8217;s only one left.\u00a0 Obviously there&#8217;s a bunch of chrome stuff, but when I look at detailed profiles it&#8217;s hard for me to tell what things fall into that category and what doesn&#8217;t.\u00a0 (One thought I had was that it might be worth doing some profiling on Mac, because it&#8217;s possible on Mac to close all browser windows without closing the browser itself.\u00a0 Would all this chrome memory still remain in use in this case?)<\/li>\n<li>Each time the bug reporter re-did the open\/close cycle, the Uss after closing the tabs crept higher.\u00a0 In the post-fix run, it was 108,909KiB the first time through, but the next three times through the figure was 121,552 KiB, 123,692 KiB, 127,588 KiB.\u00a0 That smells like another leak (or more than one).<\/li>\n<\/ul>\n<p>I read a lot of browser-related threads on tech websites.\u00a0 They almost always descend into slanging matches where people explain why browser A is awesome and browser B sucks.\u00a0 My perception from these threads is that memory leaks (be they real or perceived) are one of the things people complain about most with Firefox.\u00a0 This is usually based on a measurement similar to the one described above &#8212; the person browses for a while, closes all their tabs except one, and memory usage is still high.\u00a0 I&#8217;d love to hear any ideas people have about how to improve things on this front.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently wrote about bug\u00a0654106, a memory leak that has been fixed.\u00a0 In bug\u00a0653817 the reporter made some measurements that show this leak was quite a bad one.\u00a0 The reporter measured &#8220;Uss&#8221; using procrank on an Android device.\u00a0 This page says: &#8220;Uss is the set of pages that are unique to a process. This is [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,4544],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/694"}],"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=694"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/694\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}