Firefox Working to Fix Memory Leaks 555
Christopher Blanc writes "Many Mozilla community members, including both volunteers and Mozilla Corporation employees, have been
helping to reduce Firefox's memory usage and fix memory leak bugs lately. Hopefully, the result of this effort will be that Firefox 3 uses less memory than Firefox 2 did, especially after it has been used for several hours." Here's hoping. Frequent restarts of things on my computer make me furious. I can't imagine why anyone would tolerate such things.
Re:about time! (Score:2, Informative)
Try Opera (Score:0, Informative)
Restarting Isn't much of a problem (Score:5, Informative)
I tolerate it with an extension that provides a restart button on the toolbar. There are several such extensions. It's also useful for when one wants to quickly restart after installing/enabling/disabling an add-on/theme.
And of course, said extensions reload Firefox with the windows/tabs you had open.
Re:Symmetry (Score:3, Informative)
Re:I thought this was OSS? (Score:3, Informative)
Observing the existence of a memory leak, and knowing where to fix it in your code, are two VERY different things.
- Jesper
Re:Symmetry (Score:3, Informative)
Re:Symmetry (Score:3, Informative)
Which brings my second point - even with your original version, this cannot always be done in some languages as some languages remove the ability to free resources. For example, so far as I am aware - and so far as I can tell - Java cannot free memory resources outside of the garbage collector [sun.com]. So much for a programmer being able to manage their resources properly - this is probably also one of the big reasons Java sucks at performance.
Re:C++ long-in-the-tooth? (Score:4, Informative)
Because YOU allow it! (Score:4, Informative)
I consult for someone who uses ACT! 2005. When they got the upgrade notice, they asked me to check it out. I spoke to ACT! support and they told me "We improved performance by releasing resources that we are no longer using." I said, "THAT IS A BUG FIX!" Anybody writing code outside of school should be doing it, and if I was grading their code, I would take points off for that.
I'd like to see some of these software companies that do this get sued for such poor coding practices.
Re:C++ long-in-the-tooth? (Score:5, Informative)
Actually I'm pretty sure they're in denial as to the cause of their problems. Announcing they're working on fixing "memory leaks" just supports their ability to continue their delusion.
They're not in denial. They're working on tamarin [mozilla.org], a replacement/upgrade of their javascript engine based on the same engine that's in flash 9 / actionscript 3.
Tamarin will run javascript 2, which will to do javascript what the move from actionscript 2 to 3 did for flash/flex. In short: it will make non-toy applications easily done, instead of just marginally feasible. They plan to migrate the firefox UI and extensions to javascript 2, which should negate the performance issues. Only problem: it won't be ready for FF3.
Re:You're already tolerating it by using it at all (Score:4, Informative)
You say that, and you compare it to IE. The only environment where I know people keep a firefox process open for days is on the mac, which doesn't run IE anymore (and btw, safari 2 leaks like a sieve too in my experience). Yes, I have to relaunch ff on my mac every few days. But on windows every time I close my last window, the browser shuts down and all memory is reclaimed. So, on platforms that are not mac, and for "normal" use patterns (i.e. don't leave a browser window with sites open for days), this is a non-issue.
Thiis page may be informative about the issue of memory in firefox: http://plugindoc.mozdev.org/faqs/memusage.html [mozdev.org]
Firefox memory leaks - (X11 specific) (Score:5, Informative)
TIME+ PID USER CODE VIRT SWAP RES SHR S %CPU %MEM P COMMAND
391:42.00 30262 root 1712 864m 481m 383m 5636 R 20.5 38.0 0 X
19:54.97 5473 me 9.9m 350m 202m 148m 18m S 0.0 14.7 0 firefox/firefox-bin
xrestop shows this:
res-base Wins GCs Fnts Pxms Misc Pxm mem Other Total PID Identifier
3600000 295 62 1 2664 119 621592K 12K 621604K ? Firefox Working to Fix Memory Leaks - Mozilla Firefox
In other words, X has over 600MB of memory holding pixmaps for firefox. This grows every time I open a page/tab with images in it.
Closing pages/tabs does not free the memory from X, nor does lowering firefox's various cache settings in the preferences dialog and about:config. Quiting firefox causes X to release the memory. I have to do this at least once a week.
The memory bug is also a CPU hogging bug. (Score:5, Informative)
The CPU hogging bug in Firefox may be caused by inadequate allocation of resources. Maybe the chaining of the event handler code with numerous windows open is an issue.
Firefox crashes Microsoft Windows. Apparently there is a bug in Windows, or more than one, that causes the entire Microsoft Windows OS to become unstable when Firefox starts CPU hogging. In any case, the only way to get Windows back to a stable state after killing Firefox is to re-start the computer.
It's interesting that Firefox can be used to show that Windows is an unstable OS, in some cases. Linux is completely stable; it is only necessary to kill Firefox to regain resources.
The Firefox CPU hogging bug occurs only during heavy use of Firefox, with many Windows and tabs open for several hours, such as happens when someone in purchasing in a corporate environment is researching computer parts. The problem is made worse if the computer is hibernated or put in standby.
If you open a lot of windows and tabs in Firefox on a laptop, and put the laptop in and out of standby, you will eventually notice that the laptop fan is running all the time, even when there is no activity. That's the CPU bug, and it can potentially shorten the life of your laptop. The fan is often the laptop component that fails first.
It is interesting to note that the latest version of Opera also exhibits CPU hogging, but much less frequently. However, using Opera is not as comfortable because of poor design decisions in Opera.
See: Firefox is the most unstable program in common use. [slashdot.org]
Firefox developers apparently game the system by abusing those who report bugs: Mozilla Foundation Top 20 Excuses for Not Fixing Firefox Bugs [slashdot.org].
Firefox development sometimes resembles playing. [slashdot.org]
Basically, this seems to be the underlying problem: Winifred Mitchell Baker [wikipedia.org], the CEO [mozilla.com] of Mozilla, is a socially uncomfortable lawyer who became CEO when no one thought there was an opportunity. Now Mozilla Foundation is making millions from designating Google as the default search engine.
Winifred has insufficient control over those who work for her, because she doesn't understand what they do. The Firefox CPU hogging and memory gobbling bug would take some serious troubleshooting to find, and no one wants to do the work, apparently.
Re:C++ long-in-the-tooth? (Score:3, Informative)
I agree with both of you. But I'd like to point out that Firefox has garbage collection mechanisms built-in, written in C++. But, as it turns out, garbage collection is not as simple to write as one might think and the presence of garbage collection support makes people lazy, also in C++. And of course, especially in C++ this is a Bad Thing (TM). Lazy programmers quickly start assuming that malloc() and strdup() are auto-collected as well.
Garbage collection in C++ is especially tricky, actually, because a single forgotten pointer "at the broder of the collection scope" can prevent many megabytes of interlinked "garbage collected" data structures from being detected as a loop and hence collected for real. Everybody assumes that the whole thing will auto-die and writes code accordingly, allocating like hell and not caring about resources; nobody is aware of the fact that somewhere in one single file a pointer assignment might be missing that blows their collection dreams out of the water.
Automatically != Efficiently (Score:5, Informative)
Memory leaks (Score:3, Informative)
(I'm not kidding, it is very easy to accidentally use a strong pointer, where a weak pointer should have been used. Especially in languages that doesn't support the later concept
Re:The memory bug is also a CPU hogging bug. (Score:3, Informative)
Evidence of denial. (Score:4, Informative)
Maybe Mozilla people are not in denial about that one technical issue, but they certainly have been about others. See Mozilla Foundation Top 20 Excuses for Not Fixing Firefox Bugs [slashdot.org], posted to the story 611 Defects, 71 Vulnerabilities Found In Firefox [slashdot.org].
Since that Slashdot story, many many memory leaks have been found in Firefox which have made it much more stable. But Firefox is STILL the most unstable program in common use. [slashdot.org]
Re:About time (Score:3, Informative)
I have yet to see an actual Firefox developer blame users for memory usage issues. Anyone actually working with the code knows that there are problems that need fixing.
What I _have_ seen are fanboys who've never looked at the code making claims about what is or is not leaking without a basis in reality.
The fact is:
1) There are some leaks in Gecko
2) There are some leaks in the Firefox UI
3) There are some leaks in extensions
4) There are some behaviors in all three that are not leaks but do
lead to prolonged usage of large amounts of memory.
By "leak" above I mean "memory not deallocated until program shutdown", which is a looser meaning than the typical meaning of "leak" as "memory the program does not deallocate at all". In the end, the user doesn't care which is happening.
All four items above need to be addressed, though for item 4 there is the obvious question: is there utility from the user's point of view in holding on to that memory, and does that utility outweigh the memory usage. Put another way, a 5MB RAM page cache is clearly too small and a 500MB one is clearly too big (on modern hardware). The question is what a "good" size is.
> The memory buffers use up 3/4 of my memory with an empty, just launched, instance of Firefox.
You mean on Linux? A lot of that is disk buffering into RAM, right?
> but maybe I'm wrong
You're wrong.
> allocating buffer memory without even a single page loaded
To start a program you have to read it from disk. Linux in particular very aggressively buffers disk into RAM; it probably has not only all the files touched (not necessarily still open!) by Firefox as it starts, but various other programs you've started as well, the Firefox disk cache, etc, etc.
Save typing! Just give the excuse number. (Score:2, Informative)
As a community service, I'm posting this list I made. When someone wants to use one of the excuses, they can just give the excuse number. That will save typing.
Mozilla Foundation Top 20 Excuses for Not Fixing the Firefox Memory and CPU Hogging bugs.
Re:Not insane. (Score:3, Informative)
Re:Firefox memory leaks - (X11 specific) (Score:2, Informative)
The very first optimisation they discuss is: "Federico Mena-Quintero submitted a patch to make Firefox discard decompressed image data after five seconds (bug 296818)"
Click the link in the article - it leads to discussion about how X is holding all this image data for Firefox and how it's been fixed to not do that any more.
Re:Automatically != Efficiently (Score:1, Informative)