{"id":1267,"date":"2011-08-29T17:39:36","date_gmt":"2011-08-29T06:39:36","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=1267"},"modified":"2011-08-29T17:50:48","modified_gmt":"2011-08-29T06:50:48","slug":"browser-x-is-using-y-mb-of-memory-with-z-tabs-open-is-a-meaningless-observation","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2011\/08\/29\/browser-x-is-using-y-mb-of-memory-with-z-tabs-open-is-a-meaningless-observation\/","title":{"rendered":"&#8220;Browser X is using Y MB of memory with Z tabs open&#8221; is a meaningless observation"},"content":{"rendered":"<p>I read an <a href=\"http:\/\/www.winmatrix.com\/forums\/index.php?\/\/topic\/32518-firefox-7-beta-2-released-with-memshrink\/\">exchange<\/a> today about the memory usage of Firefox 7 (which is currently in <a href=\"http:\/\/beta.mozilla.org\/\">beta<\/a>).<\/p>\n<blockquote><p>It uses 600 MB of RAM with 10 tabs open (different websites).<\/p>\n<p>lol wut? I&#8217;m not getting the same results as you. I have 12 tabs open here&#8230; RAM usage rarely exceeded 300mb for me. That&#8217;s already much better than Chrome, which seems to be using 190mb for just 2 tabs.<\/p>\n<p>Memory consumption is around 300 MB for me too.<\/p><\/blockquote>\n<p>I&#8217;ve seen variants of this exchange countless times.\u00a0 Unfortunately,<strong> observations such as &#8220;browser X is using Y MB of memory with Z tabs open&#8221; are meaningless<\/strong>.\u00a0 To understand why, consider this alternative, hypothetical exchange:<\/p>\n<blockquote><p>I ran 3 different programs on my computer, they took 55 seconds to finish.<\/p>\n<p>lol wut?\u00a0 I just ran 8 programs and they only took 20 seconds to finish!<\/p><\/blockquote>\n<p>You&#8217;d never see an exchange like that, because it&#8217;s obvious that a comparison of the run-time of multiple programs is meaningless if you don&#8217;t specify what those programs are.\u00a0 <strong>Workload matters<\/strong>. And yet, people make comparisons of browser memory usage like this all the time.<\/p>\n<p>Here&#8217;s a simple example to show why this isn&#8217;t meaningful.\u00a0 I just did some memory measurements with a development build of Firefox 9, using a moderately-used profile with no add-ons installed.\u00a0 First I started it and opened 10 instances of <a href=\"http:\/\/www.google.com.au\/\">www.google.com.au<\/a>, one per tab, and the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Resident_set_size\">resident set size<\/a> (RSS) was 139MB.\u00a0 Then I re-started it and opened 10 instances of <a href=\"http:\/\/gmail.com\/\">gmail.com<\/a>, and the RSS climbed to 651MB.<\/p>\n<p><a href=\"http:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/08\/rss.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1268\" title=\"rss\" src=\"http:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/08\/rss.png\" alt=\"\" width=\"475\" height=\"426\" srcset=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/08\/rss.png 475w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2011\/08\/rss-300x269.png 300w\" sizes=\"(max-width: 475px) 100vw, 475px\" \/><\/a><\/p>\n<p>This is hardly surprising.\u00a0 gmail.com is a fully-fledged email client.\u00a0 www.google.com.au is not much more than a search box.<\/p>\n<p>Why do people so often make these meaningless &#8220;Y MB of memory with Z tabs open&#8221; comments?\u00a0 My theory is that it&#8217;s because most people have no idea how complicated web browsers and web pages are.\u00a0 Mild experience with HTML authoring is endemic &#8212; heaps of people have thrown together a basic web page, and it&#8217;s just a document with with some structure and styling, right?\u00a0 So they think the difference between the website they wrote for their scout troop in 1997 (the one with the &#8220;under construction&#8221; animated GIF) and the front page of <a href=\"http:\/\/techcrunch.com\/\">TechCrunch<\/a> is merely a difference of degree, not kind.<\/p>\n<p>They&#8217;re wrong.\u00a0 For one, HTML and related technologies are hugely more powerful and complicated now than they were a few years ago.\u00a0 Also, their scout troop website probably didn&#8217;t contain multiple megabytes of JavaScript code tracking its visitors&#8217; every move. A web browser is not a document viewer, it is a full-blown programming environment with some very sophisticated text and graphical capabilities.\u00a0 A web page is not a document but a program.\u00a0 Therefore, the memory (and CPU) usage of different web pages varies dramatically.<\/p>\n<p>Here&#8217;s a check-list of information that you should include if you want an observation about browser memory usage to be meaningful.<\/p>\n<ul>\n<li>What sites do you have open?\u00a0 The more specific, the better.\u00a0 E.g. &#8220;Gmail and a few nytimes.com pages&#8221; is ok, but listing the exact URLs is better.<\/li>\n<li>How did the browser get in this state?\u00a0 Did you just start it, or have you been using it and visiting other sites for hours?<\/li>\n<li>What memory metric are you using, and how did you measure it?\u00a0 &#8220;Explicit&#8221; from Firefox&#8217;s about:memory?\u00a0 &#8220;Private bytes&#8221; from the Windows Task Manager?\u00a0 &#8220;RSS&#8221; from &#8220;top&#8221; on Mac or Linux?\u00a0 (The full output of Firefox&#8217;s about:memory is hugely useful, because it includes dozens of highly relevant measurements.)<\/li>\n<li>In Firefox, do you have any add-ons installed?\u00a0 That can (and often does) make a big difference.\u00a0 (And that&#8217;s a topic for another day.)<\/li>\n<\/ul>\n<p>If you include all that, it&#8217;s highly likely that somebody else can reproduce your measurements, which means it&#8217;s a highly meaningful observation.<\/p>\n<p>On a related note, I <a href=\"http:\/\/blog.mozilla.org\/nnethercote\/2011\/08\/09\/firefox-7-is-lean-and-fast-2\/\">wrote previously about Firefox 7&#8217;s memory improvements<\/a>, saying &#8220;Firefox 7 uses less memory than Firefox 6 (and 5 and 4): often 20% to 30% less, and sometimes as much as 50% less.&#8221;\u00a0 The presence of the words &#8220;often&#8221; and &#8220;sometimes&#8221; in that sentence were deliberate.\u00a0 We&#8217;ve seen those numbers in our testing, but once again, <strong>workload matters<\/strong>.\u00a0 I really hope the numbers we&#8217;ve seen match what normal users see.\u00a0 In fact, I thought that people would independently test these claims shortly after I wrote them.\u00a0 But, to my knowledge, that hasn&#8217;t happened so far, even though those claimed improvements have been reported far and wide.\u00a0 (I&#8217;ve even seen numerous headlines that say &#8220;Firefox 7 to use 50% less memory&#8221;, alas.)\u00a0 Maybe once Firefox 7 is officially released people will make independent measurements.<\/p>\n<p>(A final note:\u00a0 suspicious readers may think that I&#8217;m trying to obliquely absolve Firefox from any responsibility for its memory usage by blaming web pages instead.\u00a0 I&#8217;m not.\u00a0 Firefox is doing much better now, but there&#8217;s still <a href=\"http:\/\/areweslimyet.com\/\">plenty of ways it can be improved<\/a>;\u00a0 please contact me if you want to help.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I read an exchange today about the memory usage of Firefox 7 (which is currently in beta). It uses 600 MB of RAM with 10 tabs open (different websites). lol wut? I&#8217;m not getting the same results as you. I have 12 tabs open here&#8230; RAM usage rarely exceeded 300mb for me. That&#8217;s already much [&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\/1267"}],"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=1267"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/1267\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=1267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=1267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=1267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}