9 ms·
This is why memory fragmentation is bad
- saulrh 15y agoSummary: Firefox has a bunch of long-living system javascript objects; these get fragmented in the javascript engine's heap and end up keeping alive a bunch of mostly-empty chunks of memory. Tests show that removing this fragmentation reduces Firefox's overall memory use by up to 35%.
- iam 15y agoWhat's actually surprising is that it took them this many years to get it fixed. Memory fragmentation is just as bad as memory leaks. To the user, the RAM being used just keeps going up and up until they run out of memory and have to restart FF.
- ootachi 15y agoSee my comment below; Mozilla has been well aware of memory fragmentation for years and has been constantly working to decrease it.
- iam 15y agoI remember that blog post like it was yesterday. I guess the Mozilla source code is such a gargantuan beast at this point that it really does take years to get significant improvements into it? Could explain their recent flurries of rewriting the javascript jits.
- ootachi 15y agoYes, Mozilla source code is huge (5.2 million lines [1]). But keep in mind that all browsers are roughly that big (compare Chrome, at 4.8 million lines [2]). [1]: https://www.ohloh.net/p/firefox/analyses/latest https://www.ohloh.net/p/firefox/analyses/latest [2]: http://www.ohloh.net/p/chrome/analyses/latest http://www.ohloh.net/p/chrome/analyses/latest
- hollerith 15y agoYes, I have to laugh every time a PHB refers to a web browser as a "thin" client.
- hollerith 15y agoIncidentally, does anyone know how many source lines of code iOS is? How about the software distributed on the OS X install disk minus hardware drivers?
- nikcub 15y agothis is the #1 reason why I sought out a Firefox alternative a long time ago. I like to have a lot of tabs open, and to almost never close or restart the browser. Firefox was, and to an extent still is, unusable with that type of usage pattern. I hope they get it sorted out because it is the main blocker to getting a lot of the early adopter crowd who have switched to chrome back onto Firefox.
- saulrh 15y agoMaybe you have a different use case than I do; my Chrome instance usually uses about 30% more memory than Firefox despite having a quarter as many tabs open.
- nikcub 15y agoOS X? I have 50+ tabs open atm and it is taking up 690MB in total. Chrome is also good with swaping/paging tabs that are in the background. Also, I have flash disabled, and use 3 separate builds of chrome on OS X to separate web accounts, dev instances and anonymous browsing
- saulrh 15y agoWin7. Between eight and ten tabs open, one open to Grooveshark. Everything gets refreshed every eight hours or so. Firefox usually has anywhere between five and a hundred tabs open. Both get rebooted about once every three days for updates. Chrome is at 400MB, FF is currently at 300.
- nnethercote 15y agoA colleague of mine said "eternal vigilance is the price of low memory usage". Firefox's memory behaviour has varied over the years. FF3.6 was fairly good. FF4 wasn't good. FF5 is a bit better. FF7 is looking like it will be much better. You can get Nightly builds of FF7 now (nightly.mozilla.org), and you'll be able to get Aurora builds of it in a couple of days.
- bzbarsky 15y agoThis particular fragmentation issue was introduced sometime around November 2010. So it took about 5 months to find and a bit of time to fix. > Memory fragmentation is just as bad as memory leaks. Indeed.
- Impossible 15y agoGlad to see they are finally doing something to address memory fragmentation besides suggesting that users "occasionally restart Firefox". Seems like this has been a major problem in Firefox forever.
- ootachi 15y agoMozilla has been well aware of this problem for years. See this blog post from 2008, 3 years ago, detailing the changes that went into optimizing memory use for Firefox 3, including switching to jemalloc to decrease fragmentation: http://blog.pavlov.net/2008/03/11/firefox-3-memory-usage/ http://blog.pavlov.net/2008/03/11/firefox-3-memory-usage/
- spitfire 15y agoThe sad state of affairs is that papercuts are the death of us all. We've come to the point where we have "unlimited" resources that we just throw away memory like it's going out of style. I remember a profiling of a gnome startup. It touched something like insane like 40K files. Another profile I saw removed a few bytes (unneeded, it wasn't some complex optimization) from some commonly used datas-tructure for an 50%+ speed improvement. Simply we're being cut to death by bloat and pure, sheer lazyness. a web browser has absolutely no excuse for using 500megs of ram. None. Whatsoever. I expect this comment to fall on deaf ears.
- mcpherrinm 15y agoWhat if I have 10 tabs open, each with 5 images that are 10mb each? It's not an unreasonable workload. Yet there's 500mb, right there. Never? Whatsoever? I don't think so.
- spicyj 15y agoI seriously doubt you're opening many pages with 10 MB images; even 1 MB is considered pretty large for a web image.
- mcpherrinm 15y agoRight: the example is contrived. My point is mainly that it is actually within reach, and that workload needs to be taken into consideration when making any statement about how much memory a browser should be using.
- monkeypizza 15y agoIt happens to me all the time - the "linked images" bookmarklet combined with EarthPorn reddit + autopager.
- tsvk 15y agoDid you consider compressed JPG/PNG on disk versus uncompressed raw image data bitmap in RAM? A 1024x768 32-bit image is 1024x768x4 = 3.145.728 bytes when uncompressed.
- clobber 15y agoHe mentioned wanting to get that patch into FF7. Why not FF6?
- saulrh 15y agohttps://wiki.mozilla.org/Releases#Firefox_6 https://wiki.mozilla.org/Releases#Firefox_6 FF6 has already been frozen and released to the Aurora channel; it goes to Beta tomorrow. FF7's code gets frozen and released to Aurora tomorrow.
- linker3000 15y agoBy the time we get to FF412 in a month or so I expect it will be awesome and actually ordering me free RAM from Crucial
- fomojola 15y agoRemarkable: "No we don't free chunks right away (except with the new SHRINK GC call). They survive 3 GCs because of allocation heavy workloads. Freeing and allocating right away hurts benchmark performance (bug 541140)." So they're basically saying one of the reasons a copy of Firefox with no open tabs is currently consuming 1GB of my computer's memory is because they didn't want to suck on benchmarks. Is there a flag I can set to tell the damn browser "I AM A REAL USER AND NOT A BENCHMARK, PLEASE DON'T SIT ON 1GB OF MEMORY, FREE IT IMMEDIATELY"?
- nnethercote 15y agoIn FF6 (available right now on the Aurora channel and in the next few days on the Beta channel) and later versions you can go to about:memory and click on the "minimize memory usage" button at the bottom. Maybe do it a couple of times for luck. We're working on improving things. See https://bugzilla.mozilla.org/show_bug.cgi?id=656120 https://bugzilla.mozilla.org/show_bug.cgi?id=656120 for another big improvement that will go into FF7.
- 15y ago
- wakemup 15y ago'No we don't free chunks right away (except with the new SHRINK GC call). They survive 3 GCs because of allocation heavy workloads. Freeing and allocating right away hurts benchmark performance' This is the real problem then - benchmark score vs real-world useabilty.
- KobyB 15y agoWe measure fragmentation level of disks is a unique way, that allows a central fragmentation control instead of periodical defrag. The idea can be converted to memory fragmentation - if anybody wants to join us for developing a similar tool for cases described here.. Koby http://www.disklace.com http://www.disklace.com