Please create an account to participate in the Slashdot moderation system


Forgot your password?
Firefox Bug Mozilla Software News

Notes On Reducing Firefox's Memory Consumption 297

Skuto writes "At yesterdays Browser miniconference in Ballarat, Australia, Mozilla engineer Nicholas Nethercote gave a detailed presentation about the history of Firefox's memory consumption. The 37 slides-with-notes explain in gritty detail what caused Firefox 4's memory usage to be higher than expected, how many leaks and accidental memory use bugs were tracked down with Valgrind plugins, as well as the pitfalls of common memory allocation strategies. Current work is now focused on reducing the memory usage of popular add-ons such as AdBlock, GreaseMonkey and Firebug. Required reading for people working on large software projects, or those who missed that Firefox is now one of the most memory-efficient browsers in heavy usage."
This discussion has been archived. No new comments can be posted.

Notes On Reducing Firefox's Memory Consumption

Comments Filter:
  • by Tsingi ( 870990 ) <{moc.liamg} {ta} {kcir.maharg}> on Tuesday January 17, 2012 @10:05AM (#38723846)

    I use other browsers for development, but only Firefox to browse, it's the only browser that I feel is actively protecting my privacy.

    Any other opinions on that?

    • by stms ( 1132653 ) on Tuesday January 17, 2012 @10:12AM (#38723910)

      I use firefox because my plugins make the web a much nicer place to be.

      • by Ihmhi ( 1206036 ) <> on Tuesday January 17, 2012 @12:41PM (#38726026)

        Agreed. IE is shit, and I don't trust Chrome.

        I know it might be judged as paranoid and irrational (and to a degree, it is), but I really want the bare minimum of Google products on my computer. I just don't trust them. I've seen too many previously "good" companies abuse their power once their product is entrenched on everyone's computer, and I don't want to give Google much of a chance in that respect.

        Firefox isn't only the best for my needs, it's also the least of all evils that has the features I want.

    • by bemymonkey ( 1244086 ) on Tuesday January 17, 2012 @10:23AM (#38724028)

      Agreed - and the power consumption is much lower than Chrome's (the only viable alternative, IMO) too.

      But how do I speed it up? Chrome is MUCH faster on my machine, and I'm using a Firefox profile that's barely a year old, without many add-ons installed (NoScript and ABP go without saying... ImageZoom, NoSquint... that's pretty much it). And Firefox keeps thrashing my disk (No, I'm not swapping it out for an SSD - I only have one hard drive slot in my laptop, and it's filled with a big-ass mechanical hard drive)...

      • by Surt ( 22457 )

        If your firefox is a year old, you've missed like 3 major revamps of the javascript engine. The performance difference between then and now is enormous.

        • Actually I meant that I've been using the same profile for all this time - that hasn't atopped me from upgrading to the latest FF ver

          • Forgive my ignorance, but what would using the same profile have to do with anything? It doesn't accumulate cruft like the Windows Registry or something, does it?

            • Accumulating cruft is EXACTLY what a Firefox profile does. To begin with, they're tiny... mine has grown to over 1GB in size, and Firefox thrashes the hard drive every time it's opened or closed. :(

              • You must have a lot of bookmarks :D
                Seriously, I never had such a problem. Do you have any idea what can take up so much space?

                • Looks like cache, mainly. Just deleted that and it's back down to about 200MB - that's still huge though, isn't it?

                  Don't really have that many bookmarks, and my history shouldn't be all too big...

            • It doesn't accumulate cruft like the Windows Registry or something, does it?

              I've seen suggestions that it does, particularly after upgrades, though I've not looked into the issue myself so I'm handing over unverified anecdotal evidence here.

              Even if cruft doesn't build up in the profile itself, the filesystem objects used to store it may become fragmented and spread all over your driver over time as the cache is constantly updated and the database files it keeps (for abusive locations lookups and so on) g

    • by guidryp ( 702488 ) on Tuesday January 17, 2012 @10:40AM (#38724258)

      I use FF because it is much more configurable (about:config has entries for more than any other browser), it also has more plug ins, and those plug ins it does have tend to be more effective for just about everything.

      I also don't like Google Chrome calling home all the time (uninstalled). I also have IE9 and Opera installed.

      Speed issues are moot outside of benchmarks these days (unless you are running IE7 on a netbook). IMO it is pure placebo effect to say one browser is faster than another in regular browsing on a modern computer.

      • If you don't like Google Chrome calling home all the time- there is a binary distribution of open-source Google Chromium for windows with all that callback crap removed. It's called "SRWare Iron". Well, supposedly removed- since it's binary I cannot verify that. But you can compile chromium from source yourself if you really want to. []

  • by Anonymous Coward on Tuesday January 17, 2012 @10:09AM (#38723876)

    I have 8gb of memory on my main computer. I want firefox to use up as much of it as it can to improve my browsing experience. On my netbook, I have 1, I want it to sip as little as it can. There should be an easy way to tell the browser how much memory I want used for certain tasks such as caching and whatnot. Addons should have their own seperate allocation, and each individual addon should be configurable for how much memory it can use.

    Free / Open source software is about choices to run things how you want to. With that said, I don't have much room to complain because I've never contributed code to FF.

    My main point though, is that screaming "THE RAM USAGE IS TOO HIGH" is not effective. I have a lot of ram, and I want it to be used, just not wasted; and I want more control over it.

    • by hedwards ( 940851 ) on Tuesday January 17, 2012 @10:15AM (#38723944)

      250ish MB or RAM is hardly unreasonable and is significantly better than the alternatives. If you don't like the RAM use with Firefox then you sure as hell aren't going to be happy with the competition. I haven't seen a benchmark or other comparison in a long time where Firefox didn't trounce the competition by a significant margin.

      TFA does raise an important point that the memory consumption problems are mostly with certain add ons. The vanilla install itself doesn't have those issues.

    • by ledow ( 319597 )

      I'm currently using Opera - Two windows and over 20 tabs open with different fully-loaded "big name" websites in all tabs. Some logged in, some not. Instant access to all my emails dating back to pre-2000 (with instant-narrow searching) covering some 5-6 Gb of email files on my profile (several POP and IMAP accounts all downloaded entirely to the Opera mail client) - which Opera stores as SQLite files, IIRC.

      The same Opera session has been running for about 2 weeks straight, just suspend/resume as I take t

      • by kyrio ( 1091003 )
        You forgot to point out that Opera not only uses the least amount of resources while being the fastest, it also has EVERYTHING running and installed by default. Ad blocking, tabs, flash blocking, script blocking, developer tools, mail, IRC, feed reader, completely configurable UI, themes, full control of the browser with opera:config, and the list goes on and on. On top of having all of this running, it's also brought most of those things to the market, long before these other browsers even existed.

    • by Seumas ( 6865 ) on Tuesday January 17, 2012 @11:33AM (#38725050)

      I have a lot of RAM, too. And Firefox runs like shit. It has for years and I've constantly heard the response of "no, you don't understand! it's just how it handles its back button function! That's why it uses two or three gigabytes!". I have 16gb on my primary system, so it can certainly use a few gigs if it really wants to. The question is - does it need to? More importantly, how does it perform when it's using so much RAM? That is the real problem.

      For years, I have put up with the experience of Firefox slowly grinding to a crawl. Within hours (certainly within a day at the most), it reaches 2.5gb or more memory usage and becomes unusable. Almost every action - typing, scrolling, clicking a button, entering a URL, clicking a link - causes it to hang temporarily. Sometimes for almost a minute. Click a tab. Hang. Scroll to the bottom of the page. Hang. Type in the text box. Hang. Submit. Hang. Close tab. Hang. Terrible experience.

      And, I stuck with it. Restarting the browser every few hours just became part of the experience (starting around early 3x, I believe). I primarily stuck with it, because I love Firefox and have used it forever. And Mozilla before that. And Netscape before that. Part of that is that I cut my teeth as an engineer at Netscape when I was young. It was my first real job. So I had a particular affinity for it, always. Besides, eventually they'd fix the issues. Even though they went forever claiming there weren't any memory issues . . . until sometime recently (last year, I think?) when there finally seemed to be acknowledgement of it.

      Most of all, I like having the access to extensions. Primarily, adblocking extensions. And then the tree tabs extension. And then panorama/tab candy was built into 4x. I tried Chrome several times, but their shitty handling of many tabs was terrible. I couldn't tolerate it. Firefox did it beautifully.

      And then, I finally got fed up. After all those years and all the delaying and all the excuses I made for Firefox, I decided a couple months ago that I would go full time Chrome and just see what it was really like. The result? I'm sold on Chrome, now. I can't believe I'm saying this, but I am. I never have to restart due to it behaving slow. I never have to restart due to it using too many resources. I never have it beach-balling for a minute at a time for every action I do. I never have Windows telling me the application has stopped responding. It just works.

      And here's the thing. It uses just as many resources, sometimes. Just like Firefox, I sometimes find it using as much as 3gb of memory. But where Firefox would start grinding to a halt around 1.5-2.5gb of usage, Chrome just keeps smoothly chugging along under as much as 3gb (and possibly more, but it never has used more than that, so I don't know).

      So, we can make all the excuses we want for Firefox. When it comes down to it, what matters is that my browsing habits cause Firefox to perform fucking terribly, while Chrome doesn't flinch. And when it comes down to my time and sanity, I need performance; not excuses.

      • by Belial6 ( 794905 )
        I regularly hear these stories about how Firefox grinds to a halt if it is left open. I am not the type to load lots of windows, and I shut down the browser when not using it, but my son on the other hand leaves his browser open for weeks at a time, with various flash games running the entire time. He never has these slowdowns or crashes the other people regularly report. Not with Firefox. Not with Flash.
      • I wish I could give you like a million mod points for this. I don't know if it's the memory usage or what, but Firefox just runs like shit all the time now. I had a Quad core (Q6600) and 4gb of RAM. There is no sane reason that Firefox should hang and run like shit all the time. I honestly don't care how much memory it uses but it's the fact that it runs like SHIT. You have the exact same experience I do: it hangs all the time. On everything. For no I'll open a new tab, start to type an
    • by TheRaven64 ( 641858 ) on Tuesday January 17, 2012 @11:34AM (#38725068) Journal

      I want firefox to use up as much of it as it can to improve my browsing experience

      RTFA. When FireFox has an off-by-one error in its JavaScript string concatenation code that causes it to allocate twice as much memory as it needs for JavaScript strings, it's not using memory to improve your browsing experience, it's just using memory. When FireFox is storing decompressed images in memory that never actually make it to the screen, it's not using memory to improve your browsing experience, it's just using memory.

      Most of the techniques in TFA were of general interest to anyone working on a large project, not just to FireFox.

    • I wish each tab had a flag "this tab is important -- don't release memory allocated with this tab if not visited for a while." Most of my browser memory is wasted on tabs that I didn't bother to close even though I'm not coming back to them.

    • At work I have a quad core Q6700 [] with 4GB of RAM. At home I use an older single core Athlon 64 3500+ [] with 2GB of RAM. Both machines run Windows XP.

      Both machines run FF 3.6 because I keep reading that later versions have worse memory use and UI performance characteristics.

      On both machines, I experience two problems with FF memory usage (all figures were reported as "private bytes" by Sysinternals process explorer):

      1) Memory usage keeps growing until it reaches a threshold (1.5GB on my home machine) after w

      • by Korin43 ( 881732 ) on Tuesday January 17, 2012 @02:06PM (#38727196) Homepage

        Both machines run FF 3.6 because I keep reading that later versions have worse memory use and UI performance characteristics.

        ... people say that 3.6 is more responsive (especially on older HW) than the newer versions.

        Those people are wrong. Newer versions of Firefox are *much* faster and use less memory. In fact, lowering memory usage became a priority right about the time you stopped upgrading. Ironic, eh?

      • by kyrio ( 1091003 )
        The mistake you made was using Firefox. I've used Opera on Pentium 2 systems running Windows XP and it ran quickly and efficiently, unlike any other browser.
    • by tlhIngan ( 30335 )

      I have 8gb of memory on my main computer. I want firefox to use up as much of it as it can to improve my browsing experience. On my netbook, I have 1, I want it to sip as little as it can. There should be an easy way to tell the browser how much memory I want used for certain tasks such as caching and whatnot. Addons should have their own seperate allocation, and each individual addon should be configurable for how much memory it can use.

      You can adjust the disk and memory caches on firefox still.

      The problem

    • Since so many in this thread talked about ancient history, I'll mention one. Does anyone remember the option to browse without images, from back in the day? Sometime around Netscape Navigator 2? Used to be a rather prominent option, but somewhere along the line it was quietly dropped off the menus.

      • There's the IMGlikeOpera addon that does that feature while still allowing to load per-site or individual images. It's my main reason to stick to Firefox, since Chrome addons can't prevent content from loading.

        Unfortunately that addon is one of the first addons to break if something changes, and it's not developed actively at all. On its favor, it didn't break in about 4 releases, but can happen anytime.

    • I think the big deal here is that memory was wasted, and the guy has done his profiling and tooling and has reduce the wastage dramatically.

      Good job that man.

      However, in general, apps that use lots of ram are bad for you - you may have 8Gb, but if it uses all that, your whole system is going to be slower simply because all the data is being sloshed around inside your PC. The days where more ram = fast PC is gone, today your CPU cache is the new bottleneck that turns your screaming-fast 3ghz processor into a

    • I have 8gb of memory on my main computer. I want firefox to use up as much of it as it can to improve my browsing experience.

      I have 16 GB on my main system, and I don't want Firefox sucking up all my RAM. Firefox devs seem to miss a few key points about what I think is a very common usage model: A - Browsing is not my primary Application. (For me, it's graphics software. Other people may have MS Office or an IDE.) B - Browsing is the one app where I never want to lose state. (I'm willing to close my

  • Firefox's problem (Score:5, Insightful)

    by TheLink ( 130905 ) on Tuesday January 17, 2012 @10:09AM (#38723884) Journal
    In my experience Firefox (minus plugins etc) has leaked/used less memory than Google Chrome.

    BUT, when a plugin/page starts leaking lots of memory the difference is with Google Chrome you can close the offending tab/window and the memory is freed up. You don't lose your sessions, don't lose your place on other tabs/windows. You can even reopen the page (esp if the page just slowly uses more and more memory).

    In contrast with Firefox you often have to close the entire browser to free up the memory. And IMO that's Firefox's biggest problem when it comes to memory.

    It doesn't matter how much better Firefox is on its own at memory management, in practice many people using Firefox are using it because of the plugins (otherwise they'd be using some other browser), and the plugin developers may not be so good at memory management.
    • Re:Firefox's problem (Score:4, Informative)

      by hedwards ( 940851 ) on Tuesday January 17, 2012 @10:17AM (#38723964)

      It depends which ones you're talking about. Some of them are already in their own separate process and you can kill those processes without having too much trouble. The bigger problem right now is all the freezing that goes on. I'm not sure what the problem is, but it gets a lot worse when I also have thunderbird open.

    • by DrXym ( 126579 )
      Plugins run as a separate process to Firefox now, so if it leaks you can kill the plugin container. You could also close the tab if it's responsive and clean up.
      • I do not know a way to identify which plugin corresponds to which tab. Usually, if you have a video running, it's instance of a plugincontainer take the most CPU, but as for the rest - no idea who is what. Also sometimes there are 20 or so of them (don't die gracefully) and need to be killed one by one tediously.

      • by TheLink ( 130905 )
        Sorry I was using the wrong term, should be add-ons. The other add-ons like extensions don't run as a separate process and they're often the ones that cause Firefox to leak more.

        Remove/disable the extensions and Firefox leaks less, but then you might as well use Chrome :).
    • Re:Firefox's problem (Score:5, Informative)

      by olau ( 314197 ) on Tuesday January 17, 2012 @10:57AM (#38724518) Homepage

      It doesn't matter how much better Firefox is on its own at memory management, in practice many people using Firefox are using it because of the plugins (otherwise they'd be using some other browser), and the plugin developers may not be so good at memory management.

      Actually, the presentation addressed that. They're going to add a notice to known bad add-ons at the Mozilla add-on page (social engineering), and also add a basic leak test to things done by the reviewers.

    • >In my experience Firefox (minus plugins etc) has leaked/used less memory than Google Chrome.

      I corroborate with that. Recently I got tied of Firefox and decided to try Chrome. I have got less memory usage per instance but instances open, so in sum, Chrome ends up with more memory usage. First thought that comes to mind is that with new tab - new thread/processor iedology one might bring unnecessary overhead into play. I suspect that Firefox does it only for pages which require plugins (runs its plugin-co

    • Firefox developers have been claiming that plugins were to blame for a long time (and for some FF versions they may have even been right, judging from TFA). However, there was no way to do something about it, or even just find out which plugin was the problem. TFA finally gets this:

      Although these leaks are not Mozilla’s fault, they are Mozilla’s problem. Many Firefox users have add-ons installed -- some people have 20 or 30 or more -- and Firefox gets blamed for the sins of its add-ons.

      Now they are going to improve reviews and make it possible to mark add-ons as memory-hogs / -leakers.

  • i won't be taking TomsHardware's word for it since I run Linux and they didn't even bother testing with it. but it does motivate me to perform my own checks. memory usage and sluggishness were the reasons i ditched firefox for chromium last year.
    • by Anonymous Coward on Tuesday January 17, 2012 @10:22AM (#38724008)

      Yeah, most of the improvements were in the last 4-6 months.

      Anyone else get tired of this... "blah blah, my favourite open source browser wasn't competitive with the commercial product by an ad agency that records every keystroke I type in the URL bar a long time ago, possibly due to some addons I was running, so I just completely gave up on it and whenever a story comes up on how it has improved, I just state how it sucked at some time in the past and I'll never try it again"?

    • by fatphil ( 181876 )
      However, I also don't trust the Firefox developers because after several years of being accused of being memory hogs, and every single time staunchly denying it, brushing off such issues by saying they were "features" like "caching", they finally admitted they were in the wrong. When you've lied so many times, why should anyone trust you any more?

      Again, as from your perspective, that motivates me to perform my own checks. However, if they don't provide a ready-built linux/ppc64 .deb with correct dependencie
    • by PybusJ ( 30549 )

      I've been running recent firefoxen on 64 bit Ubuntu with over 340 open tabs. It used over 1.5Gb RAM, but that seemed reasonable in the circumstances. Chromium failed entirely with a fraction of the tabs.

      On the other hand, I did find a firefox extension a couple of months ago which managed to leak over 1Gb/day (I'm afraid I can't which it was).

      • by Thud457 ( 234763 ) on Tuesday January 17, 2012 @10:50AM (#38724426) Homepage Journal

        with over 340 open tabs

        I think it's time for PybusJ to admit he has a pr0n problem...

      • by pmontra ( 738736 )
        Amazing. How do you manage all those tabs? I bet there are desktop environments that crash with a fraction of that number.
      • by Belial6 ( 794905 )
        Was this just to see what would happen, or are you actually using 340 tabs. I hear about people running huge numbers of tabs, but I would think that over a certain number of tabs, the time you would save by having the page preloaded would be dwarfed by the time spend trying to find the tab in the mess tabs.
      • When you're up to 340 tabs, it's time for some bookmarks. There is no chance in hell you regularly use 340 tabs. If you do, you are the .0001%, and it's time to start coding your own browser because you have needs that no one else does.
  • Pale Moon browser (Score:5, Interesting)

    by kriston ( 7886 ) on Tuesday January 17, 2012 @10:42AM (#38724294) Homepage Journal

    Windows users should investigate the Pale Moon browser over at Firefox optimized and without all the gunk.

  • by Windwraith ( 932426 ) on Tuesday January 17, 2012 @10:48AM (#38724378)

    Firefox is the app that uses the most RAM in my system, has always been, even more that Skyrim under WINE. I tried Chrome for a while, and while I didn't dislike it, I simply didn't want to forfeit my customized environment.
    However, I never saw Chrome as using any less RAM. I usually got Firefox with 20+ tabs open (and around 100 in "not loaded in RAM" mode with the new features, think old BarTab) grouped in Panorama groups. In Chrome, because tab space is small, I usually had around 20, and both browsers were consuming 400mb of RAM each. I'd say Firefox uses LESS memory overall.
    Thing is, firefox FEELS slow. Try to open Youtube's subscriptions page and you'll lose control of the browser for at least one second.

    I can easily see people unable to close their porn when their significant other enters the room. Porn moves the world, thus people would prefer to use Chrome for porn. Thus Chrome's usage rises while Firefox's decreases. If Mozilla makes it more convenient to use Firefox for porn, the browser usage will crush Chrome.

    • by pmontra ( 738736 )

      Same for me but that's expected. What have I open on my Ubuntu desktop now? FF, Skype, Thunderbird, terminal, emacs. FF looks like the most complex application among them and the one with more data inside (many open tabs). I run top, sort by virtual image size and I see dropbox coming first (WTF?) in front of FF. Then nautilus and thunderbird as distant 3rd and 4th. Then clock-applet (wow). Dropbox and clock-applet are two really surprising memory hogs. I still remember when the process that filled my memor

  • by nitehawk214 ( 222219 ) on Tuesday January 17, 2012 @11:15AM (#38724774)

    ... its just accidental memory usage.

    Oh good, I was starting to get worried there.

    • Can't tell if you're being snarky. A memory leak is a very specific thing (pointer lost before free'd). If this happens in a loop or some other repeated code, memory usage grows out of hand with no recourse. Accidental memory usage is a much less concerning problem, because it's relatively straightforward to deal with during execution. It's also less likely to grow unbounded.

  • I get warnings from AVG about every other day warning about FF memory usage looking suspicious. I'm pretty sure I'm not infected with anything. But having say 3-4 tabs open on Win 7 (might be the problem ;-)) uses ~560MB of RAM. Not overly complex sites either, /., coding site, youtube say (not playing a video). That said I rarely hit 80% of RAM used overall so I don't really care how FF uses my RAM other than if more RAM implies slower because more stuff has to go back and forth to the CPU. It could just m

  • by kbg ( 241421 ) on Tuesday January 17, 2012 @12:17PM (#38725712)
    I have never understood why memory leaks are so problematic to find. When I was programming in C long ago and had memory leaks, I simply created my own wrappers for malloc and free that stored where in the source code it was being called from, then at the end of the program I could simply check this list and it would display all the memory that had not been released and the corresponding line in the source where malloc was called.
    • by BZ ( 40346 ) on Tuesday January 17, 2012 @02:18PM (#38727334)

      You should read the article, which actually touches on this. One issue is that a "memory leak" can include memory that does in fact get released at shutdown, especially in garbage-collected systems (not a problem in C, of course).

      So you can have situations where you close a tab but its memory is kept alive for a while because an extension is referencing it. Not a leak in the C sense, but a leak in the sense the user cares about.

    • The problem is not finding where in the source malloc was called. That is easy. The problem is finding where free wasn't. That is harder.

  • I don't remember right now the setting, but what finally 'fixed' FF's big memory usage for me was reducing the number of pages from the history that it keeps in memory, in case you hit the 'back' button.

    There's a setting that controls this. I think it's browser.sessionhistory.max_entries Search for that.

    If you browse image-intensive sites, I saw memory usage get up to 4-6GB before. Now, it never goes over 1GB, with 50 misc tabs open still.

"Let every man teach his son, teach his daughter, that labor is honorable." -- Robert G. Ingersoll