{"id":733,"date":"2011-05-12T14:08:32","date_gmt":"2011-05-12T03:08:32","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=733"},"modified":"2011-05-12T14:08:32","modified_gmt":"2011-05-12T03:08:32","slug":"a-better-aboutmemory-stage-1-5","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2011\/05\/12\/a-better-aboutmemory-stage-1-5\/","title":{"rendered":"A better about:memory: stage 1.5"},"content":{"rendered":"<p>I just landed a bunch of changes to about:memory (<a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=648490\">bug\u00a0648490,<\/a> <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=653630\">bug\u00a0653630,<\/a> <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=654041\">bug\u00a0654041,<\/a> <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=655638\">bug\u00a0655638,<\/a> <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=655583\">bug\u00a0655583)<\/a>.\u00a0 Mostly they just fix some minor problems;\u00a0 if you&#8217;ve seen negative numbers in about:memory since the revamp hopefully you won&#8217;t any more!\u00a0 (Please tell me or file a bug if you do.)<\/p>\n<p>But there&#8217;s one cool new feature:<\/p>\n<p><a href=\"http:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/05\/gc-buttons.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-734\" title=\"gc-buttons\" src=\"http:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/05\/gc-buttons.png\" alt=\"GC buttons\" width=\"562\" height=\"214\" srcset=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/05\/gc-buttons.png 562w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/05\/gc-buttons-300x114.png 300w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><\/a><\/p>\n<p>At the bottom of about:memory there are now three buttons.\u00a0 Here are the &#8220;title&#8221; attributes for each one, which show up as tool-tips if you hover your\u00a0 mouse over them, and explain what they do.<\/p>\n<ul>\n<li>GC: Do a global garbage collection.<\/li>\n<li>GC + CC: Do a global garbage collection followed by a cycle collection. (It  currently is not possible to do a cycle collection on its own, see bug  625302.)<\/li>\n<li>Minimize memory usage: Send three &#8220;heap-minimize&#8221; notifications in a row.\u00a0 Each notification triggers a global garbage collection followed by a cycle collection, and causes the process to reduce memory usage in other ways, e.g. by flushing various caches.<\/li>\n<\/ul>\n<p>As far as I know this is the first time users have been able to trigger GC and CC easily in a vanilla browser.\u00a0 It&#8217;ll be particularly useful when analyzing memory usage, e.g. trying to determine if there&#8217;s a leak.\u00a0 Often in that case you want to trigger a GC and\/or CC to make sure that the memory stats aren&#8217;t currently inflated by dead objects, and it&#8217;s now really easy to do so.<\/p>\n<p>On a related note: it&#8217;s important that the memory reporters used to generate about:memory be correct, and that the memory be categorized the right way.\u00a0 (Otherwise you can end up with nonsensical output like the negative numbers I mentioned earlier.)\u00a0 For example, I just discovered that the JavaScript heap can be allocated on the heap or directly via mmap\/VirtualAlloc, depending on whether MOZ_MEMORY is defined or not (see <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=656520\">bug 656520<\/a>).\u00a0 On Mac, MOZ_MEMORY is not defined (because it currently doesn&#8217;t use jemalloc) and so the GC heap was incorrectly being categorized under &#8220;Used Heap Memory&#8221; instead of the &#8220;Mapped Memory&#8221;.<\/p>\n<p>I&#8217;ve checked all the reporters as best as I can.\u00a0 I&#8217;m pretty confident now that all the JS and storage (SQLite) reporters are correctly categorized as &#8220;heap&#8221; or &#8220;mapped&#8221;.\u00a0 I&#8217;ve looked at the others and I think they&#8217;re right, but I&#8217;m not totally certain.\u00a0 More specifically, the reporters in the following screenshot are currently categorized as &#8220;heap&#8221; (i.e. allocated with oe of: malloc, calloc, realloc, posix_memalign, operator new, operator new[]).\u00a0 If anyone knows that to be false, I&#8217;d love to hear about it.\u00a0 In particular, I&#8217;m worried about image-related memory that might be stored in video RAM;\u00a0 I already adjusted two reporters (gfx-2d-surfacecache and gfx-2d-surfacevram) for this reason.<\/p>\n<p><a href=\"http:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/05\/Screenshot-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-735\" title=\"Screenshot-1\" src=\"http:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/05\/Screenshot-1.png\" alt=\"about:memory screenshot\" width=\"466\" height=\"367\" srcset=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/05\/Screenshot-1.png 466w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/05\/Screenshot-1-300x236.png 300w\" sizes=\"(max-width: 466px) 100vw, 466px\" \/><\/a><br \/>\nThanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just landed a bunch of changes to about:memory (bug\u00a0648490, bug\u00a0653630, bug\u00a0654041, bug\u00a0655638, bug\u00a0655583).\u00a0 Mostly they just fix some minor problems;\u00a0 if you&#8217;ve seen negative numbers in about:memory since the revamp hopefully you won&#8217;t any more!\u00a0 (Please tell me or file a bug if you do.) But there&#8217;s one cool new feature: At the bottom [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4550,30,4544],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/733"}],"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=733"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/733\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}