Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Mozilla The Internet Software

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.
This discussion has been archived. No new comments can be posted.

Firefox Working to Fix Memory Leaks

Comments Filter:
  • about time! (Score:4, Insightful)

    by downix ( 84795 ) on Monday September 24, 2007 @12:32PM (#20730379) Homepage
    Too many apps nowadays just throw out RAM like it was yesterdays newspaper! It is sloppy coding, and I'm tired of having to put 2GB of RAM into a system just to surf the net nowadays.
    • Re: (Score:2, Informative)

      by tritonman ( 998572 )
      Half the time when I start having memory problems on my PC, I look at firefox (which is just has one tab open with yahoo mail) and it is using like 400 megs of RAM.
      • by Futurepower(R) ( 558542 ) on Monday September 24, 2007 @01:39PM (#20731483) Homepage
        What people call the memory gobbling bug is actually also a CPU hogging bug, and it is still present in Firefox version 2.0.0.7, even though the bug was reported perhaps 5 years ago. Versions 2.0.0.7 and 2.0.0.6 are far more stable than previous versions, but Firefox is still the most unstable program in common use.

        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: (Score:3, Informative)

          by colfer ( 619105 )
          Some valid points, but FF has a fix for the Hibernate bug, maybe more fixes coming, see Bug 213637 and its friends. That fix will be in 2.0.0.8, while 2.0.0.7 was an emergency release for the "Quicktime abuses Firefox command line parameters" vulnerability.
        • Re: (Score:3, Interesting)

          by Verte ( 1053342 )

          Maybe the chaining of the event handler code with numerous windows open is an issue.

          I think you've hit the nail on the head. Here's an experiment. Find a page with a heap of links on it. Make sure what they link to is not too huge, and doesn't open any plugins, or anything. Now, quickly, try to open the links by right clicking and choosing 'open in new tab'. You should be spending a while waiting for the menu to open. That the page you are viewing becomes unresponsive while a new tab is being created points at really horrible threading. It seems the browser is, to some degree, doing work

      • by Futurepower(R) ( 558542 ) on Monday September 24, 2007 @02:47PM (#20732583) Homepage
        MOD PARENT UP.

        See this +5 comment posted below: Firefox's problem is architectural and not one of garbage collection. [slashdot.org].

        Quote: 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. [my emphasis]

        A +4 comment to that comment discusses Firefox's "four separate memory allocation schemes":

        "1. Custom malloc/free implementation. (Yes, custom - not from libc.)
        2. C++ new/delete operators, which for all I know may be overridden to use their malloc/free.
        3. One of the first two with reference counting to decide when to free/delete.
        4. JavaScript mark-and-sweep GC.

        Dealing with this causes some truly insane hacks..."


        Then read the comment they don't want you to see: The memory bug is also a CPU hogging bug. [slashdot.org] At present, it is marked -1 Flamebait. However, that comment begins to discuss apparent social problems at the Mozilla Foundation, and some of the same material has been marked +5 in the past.
    • I completely agree. I only have 384MB on the machine from which I'm writing this. There isn't room on the mb for any more than that. I got totally tired of the system seizing up when I used to use Firefox. So I switched to Opera. That's not completely immune to seize-up/memory concumption problems either. So I'll keep an eye open for significant improvements to FF, and just possibly switch back if they fix the memory bugs.

      I hope they won't totally forget the folks using older-specification systems, bu
    • I consistently open 10-20 tabs in Firefox and it hardly ever gets over 250 MB of RAM use. I think that's acceptable. I have other beefs with Firefox, such as the PDF crash issue (Maybe this is an adobe problem, I don't know.) and other random crashes that have been happening lately. There was just a recent update though so maybe the random crashing will stop.
    • by www.sorehands.com ( 142825 ) on Monday September 24, 2007 @01:10PM (#20731041) Homepage
      It is because people accept poor programming as the norm. Oh, yeah, just reboot it and it'll be fine.

      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.
  • Bloat in general (Score:5, Insightful)

    by pipatron ( 966506 ) <pipatron@gmail.com> on Monday September 24, 2007 @12:32PM (#20730385) Homepage
    I don't mind the memory. I have plenty of gigs even in my laptop. What I mind is the general slowness that I experience with Firefox, and that makes me use Opera on my laptop even though I would feel better using an open source browser.
    • Re: (Score:3, Insightful)

      by tknd ( 979052 )

      I agree! Except I can't fully blame firefox. I also have a lot of blame on websites and the direction some sites have gone. Take for instance, slashdot and even more annoying digg. The weight of the website has gotten considerably higher for no good purpose other than to look better. I can't argue against looks. Looks sell. But on the other hand it hinders the general experience as websites keep adding more and more layers making the browser's job more and more complex. Websites and website developers are

  • but but (Score:5, Interesting)

    by svendsen ( 1029716 ) on Monday September 24, 2007 @12:33PM (#20730399)
    everytime I mentioned the memory issue I was always told it was a plugin or there was something wrong with my system or something about my mother and a donkey. Certainly firefox fan boys wouldn't have just attacked me because I questioned something...would they? :-D
    • Re: (Score:2, Funny)

      Could be worse, you could have questioned Firefox's memory handling on a Beowulf cluster of Linux boxes conveniently cooled with a hobby-built liquid nitrogen heat exchange.
    • Exactly my thoughts. I'm constantly told things like, "There's no memory leak! It's a feature to help you undo closed tabs!" When my memory usage routinely passes 250MB with an average of only 4-6 tabs open through a session (with many tabs being closed along the way), it's not a feature. It shouldn't be remembering 12 tabs past.

      Or they blame my "extensive" list of plugins, even when on one system I have only about a dozen total, most of them minor functionality enhancements like Copy Plain Text and PDF
    • Re:but but (Score:5, Interesting)

      by MBCook ( 132727 ) <foobarsoft@foobarsoft.com> on Monday September 24, 2007 @12:48PM (#20730659) Homepage

      I've heard that too. I use FF on my desktop at work with one or two plugins (FlashBlock and FireBug, mostly). It does leak memory after enough time. Closing the browser always fixes it, so it's not much of a problem.

      That said, if a plugin leaks memory, there are a few options. First, the system should know. Even if the plugin in used constantly, I should be able to open the extensions options panel and see how much memory each one is using, so I can identify the culprit. There should be a warning system ("Plug-in 'MemHog2' is using 500MB of ram, close/ignore/disable?").

      Also, when a plugin isn't in use, then it shouldn't cause a problem. Let's say that the problem is Flashblock. If it isn't actively rendering (say I only have one window/tab open and it's pure text, no flash/etc) then it really shouldn't be using any memory. If I have FireBug inactive it should use next to no memory (when I have it actively checked CSS/JS/etc I expect it to use memory).

      I'm glad they are working on this. I've heard this complaint for a while. But even if the problem is the plugins, it needs fixing or roping in.

      How about being able to set memory limits for plug-ins, Mac OS 1-9.x style? Maybe total, maybe per active page, maybe both. Just a random idea.

  • by realdodgeman ( 1113225 ) on Monday September 24, 2007 @12:33PM (#20730407) Homepage

    Here's hoping. Frequent restarts of things on my computer make me furious. I can't imagine why anyone would tolerate such things.


    Nobody forces you to use Firefox. You can use Opera, Konqueror, links or IE, or any other browser out there...
    • What??? You suggested IE over Firefox? I'm surprised you weren't modded down to "-20 Microsoft shill"...
      • Look at the order... I suggested Opera, Konqueror and even links over IE. But I use Firefox myself, and I think it is the best browser despite of it's memory leaks. I just wanted to point out that Firefox is not alone. If you don't like it, find something else, or stop complaining.
    • by suv4x4 ( 956391 ) on Monday September 24, 2007 @12:58PM (#20730833)
      Nobody forces you to use Firefox. You can use Opera, Konqueror, links or IE, or any other browser out there...

      Firefox was supposed to be able to withstand popularity, unlike IE. Look at it now: people say it's slow, RAM hog, and hackers have started attacking it successfully just as much as IE.

      At least we see it for what it is: the stick in Microsoft's eye that made them resume IE development.

    • Nobody forces you to use Firefox. You can use Opera, Konqueror, links or IE, or any other browser out there...

      Maybe not, but in the Windows World, Opera is not a viable alternative to many people who find the Opera UI to be excessively daunting for casual use.

      The thing that has irritated me about this is that for a very long time, the FireFox leadership has insisted that there where no memory issues, that it was a specific type of use profile, and that if you knew the secrets of how to tweek the configurat

  • by wwmedia ( 950346 ) on Monday September 24, 2007 @12:34PM (#20730411)
    too little too late some people i know have switched to alternatives like Opera or back to IE7 (both use substantially less resources on windows) due to all that ram hogging
    • by IndustrialComplex ( 975015 ) on Monday September 24, 2007 @12:38PM (#20730477)
      You know they messed up bigtime when people would opt to go back to IE.
      • by wwmedia ( 950346 )
        well when a laptop has fuck all ram, and Firefox use 120MB ram to open 1 page and IE7 uses 4MB ram to render same page, something is messed up
      • You laugh, but for flash based gaming I prefer internet explorer. Now I know that isn't truly a FireFox issue, but it is the only reason I ever launch ie.
        • If only I was laughing. I've seen firefox go over 120Mb of ram on regular occasions. I HAVE to close it if I plan on doing anything else on my laptop. Often I'm running another program that is sucking down 250-300 mb of ram so tacking on an additional 120 really isn't acceptable.

          I've thought about stripping out the extentions to see if any of that helps, but it doesn't appear from this thread that they are the real issues. And if I were to strip out all the extras that I like, and end up with a browser
    • too little too late some people i know have switched to alternatives like Opera or back to IE7 (both use substantially less resources on windows) due to all that ram hogging
      Firefox is still growing. Therefore it is not too little to late, but exactly what it needs, just on time.
    • Re: (Score:3, Insightful)

      by griffjon ( 14945 )
      I use firefox on my slow, memory-starved laptop. Opera is faster, but I just can't live without adblock in the modern web age of big flashy annoying ads.

      That being said, I'd love a lighter main firefox branch that would run happily with less ram.
  • Symmetry (Score:2, Interesting)

    Are there really any memory problems that cannot be cured by strict adherance to the rule of "allocate memory at the beginging of a routine, deallocate same amount at the end"?
    • Re:Symmetry (Score:5, Funny)

      by Zelos ( 1050172 ) on Monday September 24, 2007 @12:37PM (#20730465)
      No, and there are no bugs that can't be prevented by writing perfect, correct code.

      I think the problem's in the details...
    • Re: (Score:3, Informative)

      by Anonymous Coward
      LOL, maybe if you're working in a purely functional programming language :P if that were really the case, you could allocate everything on the stack. In practice, it's often necessary to keep stuff around in dynamically allocated memory between function calls, which is why we have the heap.
    • Re:Symmetry (Score:5, Funny)

      by ucblockhead ( 63650 ) on Monday September 24, 2007 @12:42PM (#20730555) Homepage Journal
      Well, yeah. And you could prevent any memory leaks at all by requiring that malloc never be used and that everything be placed in static memory.

      Kinda hard to code like that, though.
      • Re: (Score:3, Insightful)

        by jimicus ( 737525 )
        You jest (I assume), but it is actually quite possible to code like that. In fact, in a previous job of mine part of the internal coding guidelines said "Don't use malloc".

        There is a major difference though - the problem they were trying to solve didn't involve a user interface and didn't deal with data of undefined size - it was basically a large database app.

        Of course, under the hood the compiler has to allocate memory at some point for more or less everything - but it's something the compiler can worry
    • by frantzdb ( 22281 )
      First, if that is your memory model, you should be using RAII [wikipedia.org] tools like auto_ptr [wikipedia.org]. Second, unfortunately, there are times when memory usage is more complicated. For example, when there are multiple views of the same object and that object should be deleted only when the views all disappear. I haven't looked into Firefox, but in general, I almost never trust myself with delete; it's too easy to leak memory. Even without garbage collection, you can go a long way with various smart pointers.
    • Re: (Score:3, Informative)

      Are there really any memory problems that cannot be cured by strict adherance to the rule of "allocate memory at the beginging of a routine, deallocate same amount at the end"?

      This would be better states as: "allocate memory when needed and dellocate when no longer required" - memory allocations/dellocations do not always occur in the same routine, and this only gets worse in OO programming. However, garbage-collection does not resolve the issue either. The real answer is smart design and smart

    • Recursive function calls, probably.
  • by Gertlex ( 722812 ) on Monday September 24, 2007 @12:36PM (#20730455)

    Here's hoping. Frequent restarts of things on my computer make me furious. I can't imagine why anyone would tolerate such things.

    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.
  • by mgkimsal2 ( 200677 ) on Monday September 24, 2007 @12:39PM (#20730499) Homepage
    I can't imagine why anyone would tolerate such things.

    Well, my guess is that you *are* tolerating it, as are millions of others, simply because you're using it (either older versions of IE, or current versions of Firefox). Can't comment on IE7 cause I don't use it much, but IE6 rarely crashed for me. IE3-5.5, almost daily crashes.

    5 years ago people people would constantly belittle IE users because it had frequent crashes, and pointed to the 'superior' Mozilla suite. Today, FF has morphed in to something which can't be used, with plugins, for more than a couple days max without needing to be reset. I add the caveat in there about 'with plugins' because I'm not sure I know many people who run a bare-metal Firefox. Most people use one or more extensions. This has been a huge marketing push for FF - "It's lean! Only use what you need! Get rid of 'bloat' - package everything in extensions!"

    Putting things in extensions makes the base 'leaner' but has lead to a situation where there's no centralized testing for, or even acknowledgement of, memory leak bugs (and other bugs, but this is the obvious one). I still read comments from people who claim they never have leaks with FF (we'll see some on this thread no doubt). It's not that I don't believe them, but their usage patterns are likely different from mine. I have about 6 plugins that I love to use, and I like to keep my browser going. The idea that MSIE is more "stable" than FF for daily usage should remind people that resting on your laurels is not an option. What cut the mustard 5 years ago isn't gonna cut it any more.

    • Reality check (Score:4, Insightful)

      by MMC Monster ( 602931 ) on Monday September 24, 2007 @12:53PM (#20730741)

      I can't imagine why anyone would tolerate such things.
      5 years ago people people would constantly belittle IE users because it had frequent crashes, and pointed to the 'superior' Mozilla suite. Today, FF has morphed in to something which can't be used, with plugins, for more than a couple days max without needing to be reset.
      Reality check: Most general users do not leave their browsers open for a couple days. Let alone a couple days max. In fact, I wager that most turn their computers off at the end of the day.

      No I don't have a source for my statement. But ask people you know who are not in the tech industry. The one outlier group is Mac users, who don't realize that closing a browser window doesn't take the program out of memory.
      • by sholden ( 12227 )
        How about everyone who justs flips the screen closed on their laptop when they're done with it?
    • by jsebrech ( 525647 ) on Monday September 24, 2007 @01:29PM (#20731349)
      Today, FF has morphed in to something which can't be used, with plugins, for more than a couple days max without needing to be reset.

      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]
  • An act of balance (Score:5, Insightful)

    by SplatMan_DK ( 1035528 ) * on Monday September 24, 2007 @12:49PM (#20730667) Homepage Journal
    I can certainly understand why people are tired of FF memory leaks. Being a FF user myself, with open browser windows and multiple tabs all through the day, I have seen what happens to FF after 4-5 hours of intense browsing. And don't even get me started on the PDF and Flash plugins!

    Some would argue that the problem is sloppy coding, or poor encapsulation (a typical OO programmers point of view). But please remember, that even though modern browsers are GUI apps, they are coded much like low-level server processes or protocol stacks. Low-level programming using languages like C and C++ gives you more control and better performance, but at the expense of nicer development features like garbage collection and encapsulation.

    Think about it. Would you accept a browser that rendered HTML flawlessly and with absolutely no memory leaks, but took more than a minute to render each page? I think not.

    It's an act of balance, and the problem is not _always_ "sloppy coding". It is the increasing complexity of these apps, combined with user demands which push the development towards low-level development languages. From a realistic point of view, any app. written in low-level C with as many lines of codes as FF, is bound to have bugs and leaks. (perhaps except code controlling nuclear reactors and NASA satellites, but then the price of each line of code is also somewhat different).

    We - the end users - are not without blame.

    - Jesper
  • One of the things they're adding is a time-based cache for unused images. For example, if after 5 seconds an image isn't used, it's freed from memory. This alone gave them a huge memory boost, IIRC.
  • by wizman ( 116087 ) on Monday September 24, 2007 @01:16PM (#20731141)
    I use Firefox on Mac (intel) and Windows, with the latest versions on both. I can have Firefox open for a full week on Windows without any problems, however on either Mac I have to restart Firefox about once every day or two, otherwise browsing slows to a crawl. At extremes the whole machine will start to bog down until I "force quit" (kill -9) Firefox. I'll also experience oddness where images will just stop loading.

    Running "bare bones" on all Firefox installs, no plugins other than whatever may have been included with the base distribution.

    Does anyone else notice this? I've switched back to Safari on the Mac in the meantime.
  • by Alien Being ( 18488 ) on Monday September 24, 2007 @01:37PM (#20731447)
    The biggest memory leak does not show up in firefox itself. It shows up in the X process:

                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 :0 -auth /home/me/.serverauth.30245
            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.

  • by Wolfier ( 94144 ) on Monday September 24, 2007 @02:04PM (#20731875)
    How about making at least the Javascript engine and the Flash plugin framework multi-threaded?

    IE has been lowering the CPU priority of Flash applets for years so if you have 100 Flash ads open, it won't bog down your browsing. On Firefox, try opening a couple of tabs in Yahoo and it basically grinds to a halt.

    It used to be that in NS4, I could see "nsplugin" process so I can renice that to achieve the same effect. On Firefox, it's not possible.

    And, if you happen to leave Gmail open, my CPU usage (lowly Sempron) will hike to 30% twice a minute. On IE the CPU usage stays low. I suspect it's due to a multi-threaded Javascript engine in which individual thread can be prioritized.

  • by Chandon Seldon ( 43083 ) on Monday September 24, 2007 @04:43PM (#20734407) Homepage

    Although Firefox does have some issues with memory usage (and occasionally memory leaks), that doesn't seem the be the primary cause of usability issues.

    In my personal experience with Firefox, I see two problems:

    • The whole browser locks up if a bit of JavaScript is slow - even if it's just one tab being slow out of ten.
    • The whole browser locks up if a plug-in or extension locks up - even if the plug-in is in just one tab out of ten.

    Both of these problems could be solved relatively easily with threads (in a number of different ways), but for some reason the Firefox developers have an irrational paranoia of anything that even vaguely resembles native concurrency. They say "the real problem is just response time, if we can respond fast enough in a single thread it's the same" - but then they never actually do it, and they definitely don't do anything that would let them recover from component crashes.

On the eighth day, God created FORTRAN.

Working...