On the matter of Firefox and memory leaks…

Recently our original article/rant on Firefox’s legendary memory abuse has seen an increase in comments and views; and I had intended to post the following comment in light of the article’s rebirth and the ensuing discussions in the comments.

The reply turned out to be longer than I’d originally intended, so here it is as its own post.

I’ll try to be as objective as possible in this reply:

The most important thing for frustrated end users to keep in mind is that Mozilla/Firefox cannot be held responsible for cases where incorrectly written plugins and/or extensions cause Firefox to abuse system memory – that’s the trade-off between empowering developers and keeping the code squeaky clean.

Most of the cases reported are indeed caused by one or more extensions or plugins gone awry, doing something they shouldn’t be doing, or something they don’t know how to do properly. Some of the most popular plugins for Firefox are notorious for their memory leaks; but few users realize just how dangerous they can be, and that the Firefox devs cannot really do anything about it.

At the same time, there can be no doubt that Firefox has some memory leaks in the codebase itself. They’re clearly not easily reproducible and they don’t happen very readily nor often enough because the developers have clearly spared no effort in their attempts to address this problem for once and for all. But they’re there, nevertheless.

No matter how you look at it, the fact remains that under certain circumstances, doing certain stuff on certain machines in certain ways for certain people, Firefox still leaks memory. A lot. On Mac, Windows, and Linux. Yes, on clean installs too.

Now as a systems developer (Mac, Windows, and Linux w/ their respective native APIs; embedded systems; .NET and more with years of experience), I must say that of all the bugs and problems I’ve ever encountered, there is nothing that “cannot be fixed.” To say that this behavior is out of Firefox’s hands because it’s not their code that’s causing the problem is simply not true.

I’ve experienced memory leaks like this (and worse) in my own code in the past, largely due to stupid mistakes and silly oversights. It takes extreme persistency to make memory leaks go away – a willingness to spend 24 hours on-end & non-stop crawling through code, memory dumps, and stack traces to try and find out where things are going wrong. It requires remote debugging on allegedly-affected machines. It requires reading through dozens to hundreds of sometimes clueless users describing in the most general of terms what they were doing when things went wrong. In short, it requires a lot of effort and very little recognition and a hell of a lot of hair-pulling.

But it can be done.

C++ is an incredibly powerful language. If you know the code you’re developing and the systems you’re writing it for, there’s nothing you cannot fix. Dynamic memory allocation is the biggest gift/curse in the world, but in C and C++ if you can allocate something that means you can free it. Even if you don’t have a mechanism to find out where it is and how it got there. But you just have to be cunning enough to figure out how to track them down and set them free, taking care to know when and where to do so safely…. and you have to be familiar with every single routine and how they work; which is obviously extremely difficult with codebases as large and complicated as Firefox’s.

There are even workarounds for the memory leaks (assuming they can be isolated) if the developers aren’t willing or capable of doing the aforementioned. If you’re dealing with leaky libraries that you can’t fix, in the very worst-case scenarios you can hook into them at runtime, access the functions you need, reserve the memory required, get the job done, copy only what you need,Β then free it right back. All of it. You can have helper threads or processes handle this stuff then wipe them and their memory spaces clean when they’re done to complete the memory insulation.

There’s a lot of stuff that can be done, and none of them are easy. But the journey of a thousand miles begins with a single step, and developers and evangelists denying a problem exists isn’t the way to go about addressing the matter at hand.

At the end of the day, Firefox is a great browser and any complaints about its performance and its shortcomings are only out of a sense that it can do better – that it has to in order to remain at the top of its game in a cutthroat market of only the most intense of competition.

  • Similar Posts

    Craving more? Here are some posts a vector similarity search turns up as being relevant or similar from our catalog you might also enjoy.
    1. Firefox 3 is Still a Memory Hog
    2. Firefox Cut & Paste: 1 Bug, 4 Years, No Solution!
    3. Firefox 1.5 Beta 1
    4. Firefox Download Conspiracy
    5. Firefox Copy & Paste Bug: (Not) Fixed!!
  • 24 thoughts on “On the matter of Firefox and memory leaks…

    1. As someone who was observed severe memory leaks on multiple installs of Firefox on multiple PCs under multiple operating systems. I just gotta’ say that a lot of the discussion here resembles the following:

      – I don’t have cancer.

      – Therefore, cancer does not exist.

      – Therefore, anyone who believes they had cancer is mistaken: for example, if they believe they are observing symptoms of cancer, they must either be hallucinating, or misunderstanding what they are observing.

      – Fortunately, I am here, possessed of my vastly superior intelligence and knowledge, to enlighten such benighted souls.

    2. I’ve done the “malloc()”… “free()” so many times and probably would have been in deep doo-doo if the $200,000 — $300,000 machine vision system wasn’t capable of running for days at a time. Now I’m a customer, with a $200 netbook, free browser and it seems to lock up a thousand times (200,000 / 200) times faster while it’s running with a hundred times the memory. I wonder if my own debugging might have been easier if I’d thought of keeping a global pointer table into which all the “malloc()” pointers were entered. That, and an entry with a pointer to the associated function that called the “malloc()”, might have made my own life easier. I suppose I’m terribly ignorant of current C++ practices since I retired in the days of “C” but, with both of my little netbooks crashing repeatedly (my OLPC XO running ubuntu 8.10 and my Eee PC 900 running KDE), I’m “off to the ‘Opera'”.

    3. Well, C++ memory management isn’t much different from C – all the basics (and, more importantly, smart coding skills) still apply.

      When I had an Eee 900 (900MHz Celeron, 2GB RAM, Windows XP) before I switched to a MacBook, the only browser that was bearable was Opera. Both Firefox 3 and Internet Explorer 7 locked up waaaaaaaay too often for me to use.

    4. “So far”, I’ve been one of the luck ones with no apparent problems. With Firefox that is. Application and particularly driver conflicts has been a different matter.

      Ah, yes, pointers and dynamic memory allocation in C. C, the “Write Only” language that would let you do anything with almost no type used. It just assumed you knew what you were doing and let you do it. Later came the ability to set the level of typing. Of course the stronger typing in C++ did nothing to relieve the programmer from the need to remember to free up allocated memory after using it and to not confust global variables with local variables which can create some interesting side effects. Most memory leaks I’ve seen are a result of that confusing local and global variables.

    5. Err, posted it in another post. Anyway I’m using the latest 3 branch of Firefox beta now. The memory usage is still high. With a few add-ons & 8 tabs open it’s taking up around 196 Mb now. Surprise, with a similar setup IE 8 takes up only 39 MB, hoo!

    6. Opera 10 and Google Chrome FTW! I shifted from Firefox to either one of this browsers, and so far no problems with it.

    7. I’ve never seen the source for Firefox, but “it sounds to me” as if there are multiple problems with memory allocation. That *some* of the problems require a particular set of conditions be met sounds like a conflict or conflicts where the problem may reside in Firefox, addons, other apps, or a combination of all three.

      As I said in an earlier post, I’ve been one of the lucky ones, but that is not to say I’ve not had any failures, just very few and I’ve had them in other apps when Firefox wasn’t running.

      I can imagine trying to trouble shoot from the user reports as most times I’ve been away from the machine that has the app crash, it had multiple apps running, and I have very little idea as to what it was doing with what at the time of the failure. I normally don’t sent those in as about all I could say was I think the following 4, 5, or 6 apps were running, but I don’t know what they were doing and Firefox had the following screen up. IOW, most likely pretty much useless. I also usually run multiple instances of Firefox and may even have IE running as well along with Open Office. Come to think of it, “I think” I’ve had a few more crashes in Vista than on XP Pro. I only had Windows 7 running for a few weeks on two of the machines so I don’t have any real information on that combination. I’m going to try IE8 but I view it with some caution as I tried IE7 and went back to 6.

      Yes, I like C++ as they have done much of the work for me. It pays to make good use of inheritance which helps prevent interaction between modules and the resultant side effects. I still think it’s quite possible a mistake or two with inheritance could result in some of these problems. I also think the old Nasi Schneiderman flow chart is of substantial help when troubleshooting. It can get pretty large in a hurry though with complex programs.

      I have to add that my programming skills are getting a bit rusty as I’ve been retired for 12 years now, although I’ve been keeping my hand in with some minor projects.

    8. Guys,

      do you know K-Meleon, a Gecko-based browser with a very small footprint?
      It actually runs on a Pentium II with 32MB RAM !!!

      Well if they can do it, why can’t the “developers” from the mozilla dev team?

    9. I posted on that old thread but I feel it may help to post here.

      A few things to point out.

      one) My firefox does the same thing as Mahmoud

      two) I also see this on multiple systems.

      three) Strangely I have vs 2008 running in most cases. ( also happens when not running, but its worse when vs 2008 is running )

      four) Ending ff3 is part of my daily routine.

      I love FF, its all I use, but I too wish they would take a Que and fix the memory issues. Its been apparent since I started using it pre 2.x. All of my friends says the same thing, “Yeah its a memory hog, but I love it ;)…

      To the FF defenders ,, if its not a memory hog for you, then quit defending the fact its a non issue, it is for some of us..

      I may check this thread for a bit, so if anything needs to be tested from my end let me know. I will gladly help, but I dont have to option of wiping and cleaning systems. my systems are generally load with apps. However, that never seems to change the fact FF is a hog when it come to memory.

    10. Hello, everyone.

      Mahmoud, you are absolutely correct about problems with Firefox add-ons and extensions — not only poorly written add-ons, but conflicts between add-ons/extensions that may be coded very carefully.

      I have come across warnings in the descriptions of several add-ons about conflicts with AdBlock Plus, which is the very first add-on that I install for Firefox. I run into problems with AdBlock Plus and Web site performance and, sometime, functionality.

      I typically leave third-party cookies disabled, but have encountered sites that use a third-party content provider (with a corresponding required third-party cookie) for basic functionality. I usually write an AdBlock Plus exception for that particular third-party cookie, and then disable the connection. I usually never return to such sites, simply because the information or content offered are of little, if any, real value for me. (I do not have time for entertainment or social-networking sites.)

      I cannot recall a specific add-on that conflicts with AdBlock Plus, because AdBlock Plus is the one add-on that I will not remove, but I have to wonder about the quality of the XUL code for such add-ons.

      I do not mean my next comment to be “flame bait” or anti-Microsoft, but Firefox 3.0.10 (the current version, as of this writing) consumes more memory than any other application I typically run on Windows (32-bit Vista Home Premium on a 64-bit processor with 4-MB of RAM, although I obviously am not able to make full use of 4-MB of RAM). Even if I boot in Safe Mode — which means no security software — Firefox uses more RAM than any other application or process.

      I’ve noticed that Firefox, which I tend to leave open because I am constantly using it, consumes more RAM and becomes slower with the passage of time. After several hours, I often must shut down all applications and reboot, because Firefox becomes so slow that it seems nonresponsive.

      Please note that I have Aero, the Sidebar, and all “eye candy” disabled in Vista. I don’t particularly like having Vista look like Windows 95 with updated icons, but — regardless of my aesthetic preferences — I am more productive with an opaque interface. πŸ˜‰

      Oddly, I do not have any problems with excessive memory use or performance running Firefox (Iceweasel) and the same basic add-ons on a 3.0-GHz, Pentium-4 system with 4 MB of RAM running 32-bit, Debian GNU/Linux 5. I leave a terminal window open all of the time running the ‘top’ command and Firefox is “well-behaved.”

      I should note that I experiment with other Linux distributions, but always return to Debian, and that I see memory and performance issues running Firefox running on Ubuntu, for example, which would not exist without Debian.

      Although Debian gets criticized as being “great for servers, but not desktop use,” I install the programs, daemons, and dependencies that I want and need, eschewing the “kitchen sink” approach that is unavoidable if one selects any desktop environment (whether it is KDE, GNOME, or Xfce). I am far from an expert, but I started using UNIX (SunOS) in 1989 via telnet (2400-baud dialup) using Korn shell commands, vi, and Perl to do administrative and support tasks to volunteer for a nonprofit organization (and scared to death because I had ‘root’ privileges, required for the tasks I performed). I did not realize that any type of GUI for UNIX (Motif for VAX, and CDE for Sun, back then) existed — and saw references to X in passing, but knew it was something I did not use — until 1994, when I saw a Sun terminal running Mosaic! I spent almost six years embodying the “ignorance is bliss” adage — because, even if I’d had the bandwidth to run a remote X session, it would have been a major security risk, and I would have brought up the shell immediately anyway.

      My reply obviously shares no new insights into the memory leaks that have plagued Firefox since 2.X, but I periodically review my Firefox add-ons and extensions. If do so at least once every two weeks, I discover disabled add-ons that I recall using rarely (if at all) and one or two enable applications that I know I have not used at all in the two weeks since I installed them. (Extensions, especially media related ones, often have overlapping functionality or conflict. Plus, Adobe’s Flash Player extension is the only verifiable cause I’ve found for Firefox crashes — which have stopped since I installed Flashblock several months ago. (Unfortunately, Vista’s problem reporting tool sends the version of the Flash DLL, not the version of Firefox, to Microsoft’s servers, which regurgitated an erroneous solution to upgrade to the current version of Firefox. Firefox has not crashed since I installed Flashblock; perhaps this issue has been resolved.)

      I realize that people have rendered Windows unbootable by taking draconian measures, disabling multiple services without doing any research, but there are many resources on the Web and in print describing services. Unfortunately, we all have to run services (Windows) and daemons (Linux, UNIX, and Berkeley BSD) that are dependencies for other services/daemons or applications.

      Investing time and effort into the Firefox add-ons/extensions one is running, how important they are, and what other programs, and services/daemons one is running will not resolve any inherent memory leaks in Firefox, but such steps will improve the performance of Firefox, other programs, and one’s operating system.

      Finally, the Mozilla Developer Zone has a bug reporting project, which involves signing up and installing software, so those of us who refuse to use any Web browser except Firefox can help the development team — which is the least we should do.



    11. My Firefox at work (running on Windows XP) leaks memory like a seive! It can easily take up around 700Mb and bring my computer to a crawl (I’m wondering if windows memory managemnt is weird..). Firefox on my GNU/Linux box is also a memory hog, but not quite to the same extent and it doens’t bring my box to a crawl.

      But anyway, I’ve always blamed firefox itself for some reason, I never considered the effect of add-ons. Is there anywhere that names which add-ons leak the most?

    12. Like so many others in the prior thread, I found the thread via a google-search for methods to fix the “ever growing RAM” issue with FF3.

      Yes, the problem that “doesn’t exist”…lol.

      I read that entire other thread from top to bottom; expecting to finally find a solution as the weeks of threadness ticked by.

      But instead, as seems SO sadly common with the FF ‘community’; there was nothing from that ever-friendly group but the usual denial and nastiness.

      But there -were- some gems from others. I had to laugh when I got to this post…

      Nov. 28th, 2008 at 11:52 pm
      “1.1 GB for a fucking document viewer !?”

      LOL….yeah, that sums the whole thing up all right!

      So many blind-angry fanatics telling us that 300mb or 500mb or 900mb is “ok usage for having X tabs open”.

      Uhh…sorry, no. 50 tabs times a few hundred KB each for plain pages, does NOT equal 200 freaking megabytes!…lol.

      As someone with no ‘brand’ axe to grind (in fact, I’ve been an FF patron since it was called Firebird), I’ll join the fun by offering a few observations…

      1- Very few have complained about the RAM used by -active- tabs anyway. They have complained SPECIFICALLY about two major RAM-suckages that have NO relation to number of tabs or content of tabs. To wit…

      – The FACT that FF3 fails to release memory when those tabs are CLOSED. If it eats 150-200mb to display a few plain pages, well, that’s pretty obscene, but ok. It’s the fact that it -won’t let it go- as we close tabs and open new ones, that’s the issue.

      – The FACT that FF3 sucks up RAM as time passes; even when NO tabs are being opened, NO further pages are being loaded, NO java applets were allowed loaded, NO antivirus or other ‘interceptor’ or ‘overlay’ programs are running or even installed.

      2- Much ado has been made about “add-ons”, and that it’s all their fault.

      Yes, they’re ‘outside’ code, in a theoretical sense….but practically all reasonable people will respond, and do respond, to that BS with the same logical and truthful outburst:

      “But wait!…you Mozilla fanatics told me specifically that these very same extensions were WHY I should use Firefox in the first damn place!”

      To blame a ‘rogue’ add-on is one thing; but to totally blow off ANY responsibility for ALL the plugins that are endlessly hyped as a primary reason for getting FF, is both illogical and frankly dishonest.

      For sure it’s outrageous to disclaim ANY responsibility for FF working right with -major- add-ons like Adblock-plus. These add-ons are downloadable right from Mozilla’s own website for christ’s sake! And are being downloaded by the many MILLIONS.

      How can any rational person then act surprised or ‘offended’ when people DO expect Mozilla to ensure that FF3 work properly with ABP or any other addon from the Mozilla site ???

      If the failure to release from closed-tabs, or the infinite-growth-while-sitting, were solely due to certain ‘bad’ add-ons, we would be seeing that correlation in the reports. Instead, we see essentially the -same- memory suck problems from many -different- addon-loadings. Perhaps what the ‘community’ fears is that using ANY add-on causes these RAM-suckages.

      But even if one of the ‘major’ addons like Adblock plus is causing this, then any rational outside-observer’s immediate response will be (and rightly so):

      “Well why the hell haven’t you FF folks worked WITH the guys from that MULTI-MILLION-user extension to fix it yet?? This problem’s been around for YEARS now!”

      Yeah ok, ABP and the rest aren’t -literally- bundled at the time of FF3 install. And one can play “fine-print lawyer” all one wants to…but FF3 IS in fact a ‘bundle’ as far as any real-world user or observer is concerned. It’s no different than Porsche accepting responsibility for those special optional Pirelli tires you picked out when you bought your car. That’s EXACTLY how every normal non-mozilla person sees it.

      Or, to look at it from the other direction… instead of the fanatics claiming false-credit by patting themselves on the back for all the millions who bought into FF…

      They should instead get real and acknowledge that many of those millions were REALLY buying Adblock-Plus! …”and oh yeah, whatever that platform is called that it runs on”. LOL

      Truth guys…sorry, but it’s the truth. That’s a sizeable chunk of all adoptions of FF. Gotta have function-X…so I’ll install FF so I can run it.

      For me, it was Session-Manager. No other browser had anything like it at the time…and SM is SO damn useful. OK, gotta have SM, so install FF2 so we can run it. cool.

      ABP, SM, Noscript, Firebug (I’m not a dev, but I’ve seen MANY webcoders note that they only put up with FF’s long-running mem-probs so they can use Firebug)…and a few dozen others. All MAJOR draws for switching to FF….NOT just firefox itself.

      In a delicious irony, the FF ‘community’ has, through its endless abjuration of responsiblity and piss-poor customer relations, essentially adopted the position of MS now!

      And so we’ve come full circle, with FF taking IE’s place..LOL. The FF3-launch disaster, with it totally failing to FIX the one damn problem everyone was desperate about…has left the browser-userbase RIPE for an alternative again.

      Who knows?….maybe Andreeson will come up with another winner!…lol.

      As someone else said in the previous thread…

      “Man, if browser X had Y extension, I’d switch in a hearbeat!”.

      Yeah, me too.

    13. “Mozilla/Firefox cannot be held responsible for cases where incorrectly written plugins and/or extensions cause Firefox to abuse system memory”


      that statement is so wrong it’s painfully laughable.

      mozilla slot!
      mozilla slot!

      Mozilla needs a framework into which extensions are places to manage them for the user — especially poorly developed extensions

    14. “Mozilla/Firefox cannot be held responsible for cases where incorrectly written plugins and/or extensions cause Firefox to abuse system memory”




      that statement is so wrong it’s painfully laughable.

      mozilla sloth!

      mozilla sloth!

      Mozilla needs a framework into which extensions are places to manage them for the user — especially poorly developed extensions

    15. FWIW, I installed Leak Monitor 0.4.3 And then had to disable it because of the continuous pop ups identifying leaks. About 95% of the leaks identified were apparently caused by java script functions calls from Yahoo pages.

    16. Firefox at work leaks memory like you wouldnt believe! It can take up around 650Mb and makes my computer so slow. Firefox on my Linux box also uses up a lot of memory, not the same thou and it doesnt eat at my box


    17. Average web surfer asking question about this…I already tried checking out every plugin, but the slowdown still happens. It then occurred to me that I recently turned off third-party cookies. Knowing nothing about code and if it could possibly be related, I did a search and found this post. Could it be my disabled third-party cookies slowing down firefox?

      Like David Dickerson, I leave it open all the time, being an internet writer and constantly doing research. After a few hours it starts to eat memory to the point I have to reboot. This behavior started when I turned off third party cookies. I just turned them back on to see if this will help. I wonder if this may be part of the puzzle or do you think the timing is coincidence?

    18. Known to break Garbage collector.

      Cooliris/PicLens (the idiots who develop this have done nothing to address the problem, though they are aware of the issue.)
      NoSquint (use Default Full Zoom instead)

      Avast (Webscanner module breaks garbage collector)
      AVG 9 (unknown, but various reports of memory leaks in firefox with this)
      Kaspersky IS (mozilla virtual keyboard 3 module breaks garbage collector under XP, not verified for NT6+)

      Extensions / modules causing a memory issue is easy to isolate. When doing isolation tests i load a profile with a few hundred tabs worth of facebook. Or another is the page at http://www.npi-news.dk/.

      Once memory passes 1GB, i close every single tab at once. If an extension or module is causing the garbage collector to fail, memory usage will not decrease, but opening new tabs will cause it to increase. If no such problem is present, usage will drop from >1GB back to roughly 180-200MB (or less with session max history viewers disabled). Note, sometimes opening a new tab is required for the memory drop to occur, and other times loading a couple of pages.

      Under normal operation, firefox’s memory usage will increase and decrease as thats the normal behavior of any applications memory use and garbage collection. It has only been under certain configurations that i have verified on multiple machines, that firefox will continue to use more, without releasing.

    19. does mozillagoogle not yet have a list of GC breaking extensions and plug-ins?

      There is a TINY list on mozillazine πŸ™

      testing each profile extension individually or through halving is VERY time consuming.

      Too bad there aren’t end user friend tools for finding greedy/borken extensions

    Leave a Reply

    Your email address will not be published. Required fields are marked *