Notes On Reducing Firefox's Memory Consumption
Skuto writes "At yesterdays linux.conf.au 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."
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?
What a fool believes, he sees, no wise man has the power to reason away.
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.
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.
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.
The final link actually shows Firefox is one of the most memory inefficient browsers in heavy usage.
That depends on how you look at it. With one tab open it is comparatively poor, but with 40 tabs open it's very good.
I don't particularly think FFX has even close to the best performance, but those metrics are good. What's more important, good management with a low footprint or a high one? I have to disagree with you there.
I'm already up to Firefox 9, so this must be from the ancient past, right?
If 22nd March 2011 is ancient past for you, then yes. Thanks to the new release cycle, version numbers increase every 6 weeks.
The slides talked about firefox 12.
There is a spark in every single flame bait point.
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.
Windows users should investigate the Pale Moon browser over at www.palemoon.org. Firefox optimized and without all the gunk.
Kriston
The slides talked about firefox 12.
I honestly thought this was a joke for a few minutes, till I checked the slides myself.
"None can love freedom heartily, but good men; the rest love not freedom, but license." --John Milton
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.
Citation Needed.
I am sure that many people here would like to know how you equate Ad-blocking with supporting SOPA?
Come on please tell us.
I'd rather be riding my '63 Triumph T120.
The funniest part is that Safari for Windows probably has to load extra Apple-related libraries to run. Otherwise I wonder how they can offer Apple anti-aliasing on a Windows system.
I'd be interested to see that same test performed on a Mac OS X system. What do you mean "there's no Internet Explorer on Mac!"? Who cares!
Of course it's not stupid. It's the whole reason for the feature in the first place. So that 'acceptable' ads can be shown and used to support the websites you visit. They need the money, you know. The reason it's on by default is that the ads are specially screened for their acceptability, and only ads that are deemed not annoying to users are presented.
Dump the firefox address space to a file and check the proportion that's simply text urls. For a daily user with history set to a typical value like 30 days it's shockingly large - tens to hundreds of megabytes. That's mostly the sqlite url/places db. Simple lz77 on *.sqlite gives a 50% reduction. Dictionary-based schemes would give a 95% reduction; academic work shows all urls can be coded in 4-5 bits. The few extra cycles per lookup are nearly free, and much cheaper than RAM.
There are hundreds of equally dumb design decisions holding back necessary features. Have fun waiting for a competent sandbox.
I sort of agree, except it's the standard term so everyone knows what it means.
I'd see hoarding as something slightly different anyway. Application grabs memory because it needs it. Then doesn't release it when it not longer needs it. If it then reuses that memory internally next time it needs some, that's hoarding. It's not admitting that the OS might do a better job of memory management and being greedy. Same with applications that grab more than they need on startup instead of waiting for when they really need it.
Leaking would be grabbing memory, not releasing it, "forgetting" about it (i.e. losing the pointer) and then asking for more when needed.
Sigs are so 1990s. No way would I be seen dead with one.
See page 27 of the PDF. He explains that the allocator, jemalloc, rounds up some allocation requests to easier to handle size. He calls this wastage "slop". Then look at the final point on that page - in order to reduce slop, always allocate a power of two sized block, as those never have slop.
So in order to stop the allocator wasting memory by using up more memory than requested, we're supposed to ask for more memory than we need? That seems to be a facepalm moment. Let's move wastage to where we can't measure it, so that we can't see any wastage any more. The bind moggles.
Also FatPhil on SoylentNews, id 863
... its just accidental memory usage.
Oh good, I was starting to get worried there.
I'm a good cook. I'm a fantastic eater. - Steven Brust
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 mean that FF preloads a bunch of stuff so it runs faster though (don't hear a lot of people say it is faster :-)) so tricky.
That depends on how you look at it. With one tab open it is comparatively poor, but with 40 tabs open it's very good.
And in which of these states is it most likely a typical (non-Slashdotter) Firefox user will be?
#DeleteChrome
Dump the firefox address space to a file and check the proportion that's simply text urls.
You are aware that not all of Firefox's address space is in memory, right? I'm pretty sure that Firefox does not use hundreds of MB of RAM just for storing URLs.
I love Firefox. It still has a few annoyances though. Having to sometimes manually kill the Firefox task to start a new browser window because it's "already open" is my biggest one. But, I still love its customizability over the sheer rigidness of Chrome.
That depends on how you look at it. With one tab open it is comparatively poor, but with 40 tabs open it's very good.
And in which of these states is it most likely a typical (non-Slashdotter) Firefox user will be?
What difference does it make?
academic work shows all urls can be coded in 4-5 bits
5 bits gives a total of 32 possible URLs, so this is only true for very small Internets...
Or do you mean 4-5 bits per character?
I am TheRaven on Soylent News
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.
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 which FF locks hard with close to 100% CPU use and never recovers. Closing tabs did not bring the memory usage down in a perceptible way.
This used to require daily restarts of FF but lately the problem does not seem to happen that often. A restart can still cut the memory use by half (same tabs courtesy of session restore), which helps with problem #2 below, but it takes much longer to go over 1GB.
2) Periodic "stuttering" where FF will pause for a short period every once in a while with CPU usage spikes approaching 100%. The duration of the pauses seem directly related to the amount of memory that FF uses. That, and the periodic nature of the "hiccups", lead me to believe it is related to garbage collection.
Unfortunately, it makes viewing videos when FF is running (even using an external viewer) impractical, so I have to close FF and start IE8 each time I go to youtube,
There's a bug report that was opened almost 3 years ago (and still unassigned).
The responses that I get are:
* You're using an old version.
True, but according to the comments, bug 490122 is still present in the newer versions (up to v10) and people say that 3.6 is more responsive (especially on older HW) than the newer versions.
* It's the plugins/addons/extensions.
Perhaps, but the reason I use FF at all is because of the extensions and I would expect such an "extension-centric" product to help me figure out which one is misbehaving (for example, by reporting the memory usage of each tab).
Now, reading the article and the slides, I am getting hopeful that these issues are being addressed.
I'm on FF 12a1; seems much better than the actual releases.
There are a few plug-in issues, but I'm not a big plugin user, so its not a big deal.
If someone is passing you on the right, you are an asshole for driving in the wrong lane.
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.
http://en.wikipedia.org/wiki/SRWare_Iron
--Coder
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.
Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
Citation Needed.
I am sure that many people here would like to know how you equate Ad-blocking with supporting SOPA?
Come on please tell us.
Perhaps he's Jamie Kellner, in which case the only reason I wouldn't tell him, and everybody who defends him, to go fuck themselves is that they might manage to have an orgasm in the process, and they don't deserve to enjoy themselves.
The link was not labelled typical use but heavy use. Which of those states is most like 'heavy use'?
The big surprise for me was seeing that browsers consume significantly more memory on OS/X than Windows. Look at the "-39, 2min" test for Firefox: 225MB for Windows, 717MB on OS/X. How can the same code, doing the same memory deallocations, do this? Or do the browsers implement different memory management algorithms for different operating systems? Or is the test broken? Even Safari seems to have significantly lower memory usage on Windows than OS/X. What's going on there?
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.
Don't steal. The government hates competition.
For Firefox and Safari, part of the difference is that they're 64-bit applications on Mac and 32-bit applications on Windows.
For Chrome and Opera, that's not an issue, since they're 32-bit both places.
Past that, Windows and Mac use different font and graphics subsystems. That's a pretty large chunk of memory usage right there that'll be very different. There might also be differences in allocations in various other system libraries.
Further, "the same memory allocations" can lead to very different results when different allocators are used. See http://pavlovdotnet.wordpress.com/2007/12/06/more-allocator-data-tcmalloc-edition/ and http://pavlovdotnet.wordpress.com/2007/12/04/vlad-and-analysis-of-dtrace-was-used/ for some data from a few years ago using different allocators for Firefox on Windows. At least for the Firefox version tested there the allocators are different on Windows and Mac: the Mac version uses the system allocator while the Windows version uses jemalloc. Newer versions use jemalloc on Mac as well.
I agree the result is interesting though, and having an idea of how much of it is attributable to which factor would be good. An apples-to-apples (so to say) comparison using a recent Firefox nightly with jemalloc on both Windows and Mac, running in 32-bit mode on Mac, might be interesting.
Actually adblock is theft. By using adblock, you support grand theft, burglars and, er, arsonist.
I suspect you're not actually familiar with programming, because you're making the mistake of thinking that code is fungible, like you can easily swipe a chunk of Chrome into Opera (to choose two browsers you didn't call out specifically, for the sake of impartiality :)) and suddenly a bunch of CSS properties work.
Even in extremely modular code this won't be true of internal details like this, especially in highly optimised software like web browsers where internal data structures will generally be tuned to favour performance over potential to interact with completely different software packages.
Actually, it is better if they don't look. If they look, and somehow similar code gets put into IE, then they could be taken to court. As a programmer in the field, as tempting as it may be, never ever look at another persons code unless it's BSD licensed, public domain, or similar.
I disabled every data gathering option I could find in Chrome and it still was trying to get at the internet on it's own.
I never saw Iron do any such thing. Also your "analysis" is ancient and out of date, based on Chrome 5 source, Iron now uses Chrome 16 mainline source.
Then perhaps the proper solution is exposing a memory manager API to let applications mark some blocks of RAM as "purgeable" so that they can be discarded (and rebuilt later) if the operating system experiences memory pressure. Mac OS has been doing this since 1984. For example, most cached data (DOM of recently closed tabs and windows, as well as decompressed forms of off-screen images) could probably be marked purgeable.
I wasn't saying AVG was the problem. I'm aware of FF RAM usage because AVG tells me about it periodically. I'm not that much of a nerd that I check my RAM usage all the time even when my computer isn't behaving poorly. AVG IS suggesting that something might be wrong with the app because it is using so much RAM though. Not sure if it is a generic thing like anything using > X MB of RAM gets flagged, or if it is RAM usage growth over time that triggers the warning or what. Don't really care because I ignore it since I'm no where near my RAM limit.
FYI, the second "f" is lowercase: the name is Firefox, not "FireFox". While we are on the topic the official abbreviation is FX, despite most people using FF.
There's a hidden treasure in Python 3.x: __prepare__()
The user experience on Mac is incredibly bad. Firefox is borderline useless. Cut and paste operations, scrolling after you open a new window, and many other actions are frustratingly laggy. None of the other browsers, Safari, Chromium, or Opera have this problem. It is painful to use Firefox on a Mac.
Its called letting the OS cache disk access
We appear to disagree on the meaning of "cache". It's not just the browser's "cache" of downloaded objects that would be marked purgeable. Are you claiming that cached DOMs, used for back and forward buttons, recently closed tabs, and recently closed windows, should all be written to the HDD? Or that cached decompressed images should be written to the HDD as BMP files?
You cherry picked whether to rank Firefox relative to the best or the worst in those datum. Without knowing how many browsers were tested, that data is almost completely useless.
Yep I agree. It should be ram usage + low ram not just RAM usage. All I saw for settings was to completely disable that type of warning not exclude certain apps. So I'll live with it it is just a popup balloon every few days so not a big deal.