Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Firefox Memory Leak is a Feature

Posted by Zonk on Tue Feb 14, 2006 05:42 PM
from the that's-what-they-all-say dept.
SenseOfHumor writes "The Firefox memory leak is not a bug. It's a feature! The 'feature' is how the pages are cached in a tabbed environment." From the article: "To improve performance when navigating (studies show that 39% of all page navigations are renavigations to pages visited less than 10 pages ago, usually using the back button), Firefox 1.5 implements a Back-Forward cache that retains the rendered document for the last five session history entries for each tab. This is a lot of data. If you have a lot of tabs, Firefox's memory usage can climb dramatically. It's a trade-off. What you get out of it is faster performance as you navigate the web."
This discussion has been archived. No new comments can be posted.
Firefox Memory Leak is a Feature | Log In/Create an Account | Top | 602 comments (Spill at 50!) | Index Only | Search Discussion
Display Options Threshold:
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1) | 2
  • Total cached page limit. (Score:5, Insightful)

    by Short Circuit (52384) * <mikemol@gmail.com> on Tuesday February 14 2006, @05:43PM (#14720067)
    (http://shortcircuit.us/ | Last Journal: Sunday October 14, @02:01AM)
    So there's a way to limit the number of cached pages per tab, but no way to limit the total number of cached pages, for those of us who have fifteen tabs open?

    Whoops!
    • Re:Total cached page limit. (Score:5, Insightful)

      by Rolan (20257) * on Tuesday February 14 2006, @05:54PM (#14720181)
      (http://www.error-417.com/blog/ | Last Journal: Thursday July 28 2005, @12:43PM)
      Yeah, where can I turn off this "feature"? Or, better yet, why doesn't this "feature" release memory when the tab is closed? Either of those would make me much much happier with Firefox.
      [ Parent ]
      • Re:Total cached page limit. by Anonymous Crowhead (Score:2) Tuesday February 14 2006, @06:06PM
      • Re:Total cached page limit. (Score:5, Informative)

        by masklinn (823351) <{slashdot.org} {at} {masklinn.net}> on Tuesday February 14 2006, @08:32PM (#14721266)
        1. set browser.sessionhistory.max_total_viewers to "0"
        2. It does (try opening a huge Fark photohop thread, huge as in multiple hundreds of pictures, see Firefox ramp up to 600 or 700Mb ram consumption, close the fark tab, see firefox' ram usage drop dramatically to regular ram usage levels)
        [ Parent ]
      • Re:Total cached page limit. (Score:5, Informative)

        by Anonymous Coward on Tuesday February 14 2006, @09:12PM (#14721513)
        An operating systems class might help you understand why memory usage meters are completely unresponsive in the down direction.

        See here's what happens:
        Firefox allocates memory for a rendered page. You've got 20MB allocated already, all in 3 chunks. None have enough room for the single large allocation it needs so the OS sets aside a new chunk of memory for the firefox process.
        Now it's using say 28MB of memory. And only 22MB of that is used. Well, it does a couple more allocations, some fairly permanent ones, and these get put in the newest block of memory.
        Then you close the tab. Firefox frees the associated memory. The OS changes it tables around for that block to indicate so. But it still has some stuff in that block. So guess what? Firefox' memory usage remains exactly the same.

        The solution? Use a GC system. Some Garbage Collectors (most) actually move objects to condense them in memory. This is one of the things that makes garbage collections noticeable if a lot has happened since the last one (it's gotta move a lot of RAM and change a bunch of links to said RAM). It becomes especially bad when you move into swap space ;).
        The downside? While GC advocates will often amaze you with the fact that malloc is not an atomic operation (it has a lot of work to allocate, more or less depending on the current situation of your memory chunks and the free memory on the system), malloc is still not nearly as costly as a garbage collection cycle. And, free is atomic (at least, TMK all a good implementation does is remove something from a data structure, unless it's the last part in which case it also needs to mark that memory as free).

        So, you see, no matter how few memory leaks firefox has, it still won't drop in RAM usage every time you click close.
        If you want to prove memory leaks in firefox you can. Get yourself a memory debugger (such as valgrind) and run firefox under it. Now, I'll warn you that this is harder than it sounds:
        1.) Memory debuggers are about 100x to 1000x slower than your machine natively.
        2.) Firefox is a script, not a binary, it sets up a bunch of stuff for the binary to run.
        3.) Everything you see on the memory debugger is not necessarily a leak. Some of the leaks aren't even really leaks (it's generally no big deal to leak when you're exitting because the kernel cleans that up for you).
        4.) To get any useful information on the leaks (other than size) you'll need to have compiled with debug symbols and you'll need to have the source code.

        Go ahead, post your list of firefox memory leaks. Then post your list of IE memory leaks. I bet both have some, but neither has anything major. And I bet it takes you a week to find them ;).

        [ Parent ]
        • Re:Total cached page limit. by HeroreV (Score:1) Tuesday February 14 2006, @09:56PM
        • Re:Total cached page limit. (Score:5, Interesting)

          by Edgewize (262271) on Tuesday February 14 2006, @10:41PM (#14721940)
          You're confusing garbage collection with heap compaction.

          People have written garbage collectors for C++, and they work just fine. But they do not help with fragmentation, which is the problem you're describing. That requires a heap-compacting allocator (aka a "handle" allocator). Many languages with garbage collection also use a heap-compacting allocator. C++ does not, because of a low-level language "feature": pointers, and specifically, pointer arithmetic.

          If an object moves in memory, then people have to be notified that it has moved, or they won't know where to access it. Languages like Java handle this behind-the-scenes; the system library tracks objects for you, and your program never knows (or cares) whre an individual object is.

          C++ allows direct access to system memory, and it tells you precisely where your objects are located. Programmers are then free to do all kinds of things like compute distance to other objects, or convert the location to a number and do arbitrary math operations on it.

          When an object moves, anything that refers to it needs to be updated. Well, good luck figuring that out in a language with pointer arithmetic! The system would need to magically determine whether or not a numeric value was actually a memory locations. And what if a program computed the distance between two objects, and later on used that distance to get from one object to the other? The system has no idea of what can be safely moved, and what has to stay put. So nothing can ever be moved.

          There are workarounds of course -- if you write a program with heap-compaction in mind, then you can use a "handle" system, where every object has an ID. You remember the ID, and to access the object, you ask the system for a temporary memory location. And as soon as you're done, you "forget" the memory location and let the system shuffle things around in memory. The next time you give that ID to the system, you might get back a different memory location, but you were already expecting that so your program doesn't mind.

          But handle allocation is slower, less efficient, and more annoying to use than a traditional fixed-location allocator. You have to start your project with it in mind; retrofitting existing code to use a handle allocator is a giant timesink and prone to conversion errors. And if you don't mind the loss of performance due to using a handle allocator, why are you using C++ in the first place?
          [ Parent ]
        • Re:Total cached page limit. by tricore (Score:1) Tuesday February 14 2006, @11:21PM
        • 1 reply beneath your current threshold.
      • Re:Total cached page limit. by CastrTroy (Score:2) Wednesday February 15 2006, @08:48AM
      • Re:Total cached page limit. by fantom2000 (Score:1) Wednesday February 15 2006, @11:25AM
      • 1 reply beneath your current threshold.
    • Re:Total cached page limit. (Score:5, Informative)

      by bpd1069 (57573) on Tuesday February 14 2006, @05:55PM (#14720192)
      (http://www.theflywire.com/)
      FTFA: "...For those who remain concerned, here's how the feature works. Firefox has a preference browser.sessionhistory.max_total_viewers which by default is set to -1."......If you set this preference to another value, e.g. 25, 25 pages will be cached for every tab. You can set it to 0 to disable the feature, but your page load performance will suffer.
      [ Parent ]
    • Re:Total cached page limit. by abdulla (Score:2) Tuesday February 14 2006, @05:55PM
    • Re:Total cached page limit. (Score:5, Informative)

      by SmartSsa (19152) on Tuesday February 14 2006, @05:55PM (#14720200)
      (http://www.pileofcrap.org/ | Last Journal: Saturday December 27 2003, @10:59AM)
      From the Tips & Tricks page:

      Specify the memory cache usage

              Normally, Firefox determines the memory cache usage dynamically based on the amount of available memory. To specify a specific amount of memory cache, add the following code to your user.js file: // Specify the amount of memory cache: // -1 = determine dynamically (default), 0 = none, n = memory capacity in kilobytes
              user_pref("browser.cache.memory.capacity", 4096);

              To disable the memory cache completely, add the following code: // Disable memory cache:
              user_pref("browser.cache.memory.enable", false);

      [ Parent ]
    • Re:Total cached page limit. by mnmn (Score:2) Tuesday February 14 2006, @06:15PM
    • Re:Total cached page limit. by mduell (Score:2) Tuesday February 14 2006, @08:44PM
    • Fooey on it by Sparkle (Score:1) Wednesday February 15 2006, @12:24AM
    • Re:Total cached page limit. by natmaster (Score:1) Wednesday February 15 2006, @01:36AM
  • How nice. by Pig Hogger (Score:2) Tuesday February 14 2006, @05:46PM
    • Re:How nice. by wizbit (Score:2) Tuesday February 14 2006, @05:51PM
      • Re:How nice. by Tony Hoyle (Score:2) Wednesday February 15 2006, @01:26AM
        • Re:How nice. by Bloke down the pub (Score:1) Wednesday February 15 2006, @03:53AM
    • 1 reply beneath your current threshold.
  • What a small world (Score:5, Funny)

    by Rude Turnip (49495) <rudeturnip@vald o t .org> on Tuesday February 14 2006, @05:46PM (#14720108)
    (http://valdot.org/)
    Did the Mozilla Foundation hire the same PR firm that Microsoft uses?
  • Christ is it a waste by heinousjay (Score:1) Tuesday February 14 2006, @05:46PM
  • My boss doesn't agree.. (Score:5, Funny)

    by lbrandy (923907) on Tuesday February 14 2006, @05:47PM (#14720113)
    My bos doesn't agree at all. I tried including this feature in several of my builds. My company is so regressive, we have alot to learn from the leaders like Firefox.
    • 1 reply beneath your current threshold.
  • My pet peeve! by RingDev (Score:2) Tuesday February 14 2006, @05:47PM
  • spyware with IE or memory leak with FF.. by madnuke (Score:2) Tuesday February 14 2006, @05:48PM
  • In other news... (Score:5, Funny)

    by GillBates0 (664202) on Tuesday February 14 2006, @05:50PM (#14720142)
    (http://slashdot.org/~GillBates0 | Last Journal: Tuesday July 10, @04:36PM)
    ...scientists have determined that the human appendix is not an evolutionary anomaly as previously thought, but an intelligent design feature aimed at keeping the humans guessing as to it's actual function.

    And in totally unrelated news, the Mozilla foundation recently announced that their flagship browser Firefox shall soon be renamed to Bigfoot, to reflect the software's large memory footprint.

    More breaking news on these topics at 11.

  • Doesn't seem to be true (Score:4, Insightful)

    by amliebsch (724858) on Tuesday February 14 2006, @05:51PM (#14720147)
    (Last Journal: Friday February 10 2006, @02:51PM)
    If this is true, then why is so little memory freed after the tab is closed, compared with how much it consumed when it was created?
    • Re:Doesn't seem to be true by 7macaw (Score:1) Tuesday February 14 2006, @05:57PM
    • Re:Doesn't seem to be true by ummit (Score:1) Tuesday February 14 2006, @06:17PM
    • releasing memory (Score:5, Interesting)

      by DreadSpoon (653424) on Tuesday February 14 2006, @06:25PM (#14720433)
      (http://www.awesomeplay.com/ | Last Journal: Thursday November 10 2005, @04:51PM)
      The answer to that is pretty simple:

      The heap, where dynamic allocations occur, is only allowed to grow or to be truncated. An application cannot release memory in the middle of the heap without also releasing the memory at the end of the heap.

      So let's say Firefox makes 10 one-page allocations, and frees the first 9. The memory layout might look something like:
      XXXXXXXXXU (X- unused, U- used)

      Those 9 pages worth of memory aren't being used, but it's impossible to release them back to the OS.

      Thankfully, there is some good news: when Firefox needs to allocate more memory, it can and will just reuse those 9 unused pages instead of allocating more memory from the OS and growing the heap.

      The best solution to this problem is to use a compacting garbage collector. Which is something that Java and C# and other higher-level langauges can easily make use of (and many do use them), but which C and C++ can't really make use of given the complete lack of compiler support. That's one reason why a Java or C# app can actually out-perform a similar C/C++ app, especially with a good native-code compiler and an library implementation with a modern GC.
      [ Parent ]
      • Re:releasing memory by N7DR (Score:2) Tuesday February 14 2006, @06:50PM
        • Re:releasing memory by cortana (Score:2) Tuesday February 14 2006, @06:54PM
          • Re:releasing memory (Score:5, Insightful)

            by Bloater (12932) on Tuesday February 14 2006, @07:55PM (#14721088)
            (http://maihem.org/ | Last Journal: Saturday March 18 2006, @08:59PM)
            > Wouldn't all pointer references then have to go through some kind of lookup table, so that the objects could be relocated by the runtime without breaking them?

            Only on a computer without virtual memory. In a PC (which *has* virtual memory), you just punch holes in the memory.

            What happens is a process gets an "address space", into which pointers can point, but any given address may not map onto some real storage. The process asks the operating system to map a range of addresses onto real storage which the operating system will try to map to real fast memory when it thinks it will be used at any moment. When the OS figures the memory wont be needed for a while, and something else needs some memory, the OS copies the data to disk and redirects the mapping to a proxy that will pull the data back into memory when the process tries to use it again.

            When a process knows that it won't need a section of that real storage, it can tell the operating system to unmap it from the address space.

            There are various other things that go on, but that's the simple story. From a figure posted in an earlier message, it seems that opera does pretty damned well (in comparison to most modern programs) with just the simple story, not having to rely much on nasty unreliable heuristics. Of that I am impressed.
            [ Parent ]
          • Re:releasing memory (Score:5, Informative)

            by xenocide2 (231786) <jld5445@@@ksu...edu> on Tuesday February 14 2006, @08:03PM (#14721123)
            (http://dugger.notsoevil.net/)
            That's one way, but you'd have to somehow instruct the compiler to use that for every pointer dereference. The easier method is to go in and change the values during compaction. Compaction is also known as stop-and-copy; it starts with a live set, everything you can reference from the stack, then copies over only the live objects while modifiying every pointer that uses it. It's messy but it works. Allocation is dead simple and fast. There's no fragmentation. And the runtime is limited by the live set rather than the heap size. There is a huge downside, however.

            I wouldn't recommend mixing anything resembling C pointer maths with compaction, since its incredibly difficult to tell what's a pointer and what isn't (in fact, without modifying the compiler, it can't be done in C or C++). For this reason, the Boehm collector (a collector that replaces new and delete) goes for the Mark-and-Sweep method instead of compaction. Because you dont move objects, you don't have to worry about figuring pointers. Boehm's collector is also called conservative, not only because it doesn't modify live objects, but also in that it treats any data on the stack or in the heap as a potential pointer. If the data points inside the heap, the object containing that address is marked. This can lead to false positives on occasion, but there's no helping that without any support from the compiler (again contradicting the grandparent). The good news is that a false positive isn't going to cause direct harm in mark and sweep. All that happens is that space that could be used isn't; Boehm claims this is irrelevant in today's operating systems with virtual memory, although I doubt you'd see an entire page's worth of false positives. Certainly, I can't do any better than him.

            In language R&D labs where people are paid quite well to think hard and long about things, they tend to use both approaches in what's called a "generational" collector. Young objects can be copied or collected as needed, while older objects are mark/swept away as needed. This works because old objects much more likely to stay than new ones. Last I knew, both Java and C# use generational techniques, because it makes sense in most nearly every case. However, as I described above, C++ doesn't have that, and even those libraries that replace new and delete have conventions and costs associated with it. I certainly wouldn't try to take Boehm and pidgeonhole it into Mozilla. And even if you did, it still wouldn't solve the compaction problem. All you can do is hope the virtual memory manager is doing it's job well. Even though the application and garbage collector is more likely to know what's useful than the VM manager.
            [ Parent ]
          • Re:releasing memory by angel'o'sphere (Score:2) Tuesday February 14 2006, @08:52PM
        • Re:releasing memory by mrsbrisby (Score:2) Tuesday February 14 2006, @07:18PM

        • I wouldn't know about C, but this statement is utterly false as applied to C++.
          No, its not false, its true.

          Replacing the default new and delete routines is perhaps not for the inexperienced C++ programmer, but to say that there's an complete lack of compiler support is simply wrong.

          And? What do you mean with compiler support for heap compacting (or GC)?

          Q: What has replacing new and delete with your own implementations to do with garbage collection?
          A: Nothing

          Q: How would new and delete of class A be able to compact a heap by moving allocated instances of class B down?
          A: Difficult!

          Q: So if you now add a class C you like to rewrite A::new and B::delete to also cope with class C instances?
          A: I assume you understand that EVERY delete of EVERY class needs to know EVERY other class to be able to compact the heap, yes?

          It is true that out-of-the-box C++ does not have a compacting garbage collecter, but one can certainly be written (and used, of course) with any conformant compiler.

          Indeed, but not by merly only by replacing operator new and delete.
          Existing C++ garbage collectors are very limited to more or less conservative garbage collecting. See e.g. Boehms c++ / C garbage collector.
          And, the mere point of garbage collecting if you want to start nitpicking is: you don't ever call delete.

          angel'o'sphere
          [ Parent ]
      • Re:releasing memory by syukton (Score:2) Tuesday February 14 2006, @06:53PM
      • Re:releasing memory by Anonymous Coward (Score:2) Tuesday February 14 2006, @06:57PM
      • Re:releasing memory by stefanlasiewski (Score:2) Tuesday February 14 2006, @07:03PM
      • Re:releasing memory by Klootzak (Score:3) Tuesday February 14 2006, @08:09PM
      • Re:releasing memory by hdante (Score:1) Tuesday February 14 2006, @08:41PM
      • Re:releasing memory (Score:5, Funny)

        by Profound (50789) on Tuesday February 14 2006, @08:51PM (#14721389)
        (http://xtux.sf.net/)
        >> That's one reason why a Java or C# app can actually out-perform a similar C/C++ app

        Maybe in theory, but in practice 99.9% of the world uses C++ browsers because the Java ones suck.
        [ Parent ]
      • Re:releasing memory by Alban (Score:2) Tuesday February 14 2006, @09:46PM
      • Re:releasing memory by petermgreen (Score:2) Wednesday February 15 2006, @10:42AM
      • Re:releasing memory by Duhavid (Score:2) Tuesday February 14 2006, @11:25PM
      • Re:releasing memory by IamTheRealMike (Score:2) Wednesday February 15 2006, @06:32AM
      • 6 replies beneath your current threshold.
    • Re:Doesn't seem to be true by miro f (Score:1) Wednesday February 15 2006, @02:00AM
  • about:config (Score:3, Insightful)

    by whysanity (231556) on Tuesday February 14 2006, @05:51PM (#14720155)
    (http://www.typecastsolid.com/ | Last Journal: Sunday November 30 2003, @08:05PM)
    how about a configurable option to not take up 200mb of ram? keep it as-is by default, but let power users toggle it off
  • So I'll be the first to say it.... (Score:5, Insightful)

    by JordanL (886154) <jordan.ledouxNO@SPAMgmail.com> on Tuesday February 14 2006, @05:52PM (#14720156)
    Why does Opera do the same thing faster without the memory penalties?
  • Quick Fix (Score:4, Informative)

    by I_am_Rambi (536614) on Tuesday February 14 2006, @05:52PM (#14720159)
    (http://slashdot.org/)
    about:config [about] then search for browser.sessionhistory.max_total_viewers and set it to 0. This will be 0 pages in the cache per tab. You will get a reload slow down since FF will be going out to the web. You can manually set this to 2 or whatever you want. By default FF will cache upto 8 pages per tab with 1 gig of memory or more.
    • Re:Quick Fix by dzfoo (Score:2) Wednesday February 15 2006, @05:59AM
    • Re:Quick Fix by juan2074 (Score:1) Wednesday February 15 2006, @02:10PM
    • Re:Quick Fix by masklinn (Score:2) Tuesday February 14 2006, @08:46PM
    • Re:Quick Fix by SanityInAnarchy (Score:2) Tuesday February 14 2006, @11:19PM
      • 1 reply beneath your current threshold.
    • 2 replies beneath your current threshold.
  • At least it can be changed... by The-Bus (Score:2) Tuesday February 14 2006, @05:53PM
  • Write to a file by hpygocrazy (Score:1) Tuesday February 14 2006, @05:54PM
    • 1 reply beneath your current threshold.
  • Somebody call Redmond by dedazo (Score:1) Tuesday February 14 2006, @05:55PM
  • So... by Trogre (Score:2) Tuesday February 14 2006, @05:55PM
    • Re:So... by Trogre (Score:2) Tuesday February 14 2006, @06:05PM
  • I'm all for features, but... by adminsr (Score:1) Tuesday February 14 2006, @05:55PM
  • NOT per tab (Score:5, Informative)

    by savala (874118) on Tuesday February 14 2006, @05:56PM (#14720212)

    Ben was mistaken, it's cached globally.

    See this comment [mozillazine.org] by Boriz Zbarsky:

    Ben, those numbers are NOT per tab. The bfcache is global; there are never more than 8 pages total in bfcache (and you need to have 1GB of RAM for this to happen). Most users have 3 or 5 pages in bfcache at any given time.

    and this comment [mozillazine.org] by David Baron:

    The point of bug 292965 was that the pref should be global, not per-tab. Is that not working correctly?

    (Boris and David are back-end developers; they have much more working knowledge of this than Ben does.)

    Also, there are actual memory leaks in Firefox. See this weblog post [squarefree.com] about progress on that. However, as that weblog post says as well, most excessive memory usage that people are seeing is entirely due to faulty extensions.

    • Re:NOT per tab by rbarreira (Score:2) Tuesday February 14 2006, @07:18PM
      • Re:NOT per tab by kbrosnan (Score:1) Tuesday February 14 2006, @09:41PM
        • Re:NOT per tab by kalirion (Score:2) Wednesday February 15 2006, @09:06AM
      • 1 reply beneath your current threshold.
    • Re:NOT per tab by renoX (Score:2) Wednesday February 15 2006, @07:18AM
      • Re:NOT per tab by Zathrus (Score:2) Wednesday February 15 2006, @11:00AM
        • Re:NOT per tab by renoX (Score:2) Wednesday February 15 2006, @12:43PM
    • Re:NOT per tab by hatless (Score:2) Wednesday February 15 2006, @09:28AM
  • Why doesn't closing tabs free memory? by cibyr (Score:1) Tuesday February 14 2006, @05:58PM
  • What I'd like Mozilla devs to do (Score:5, Insightful)

    by A beautiful mind (821714) on Tuesday February 14 2006, @06:05PM (#14720287)
    Let them release 2.0, but then try to focus on:
    • fixing the practically fixable bugs (not the design decisions)
    • making code performance improvements (faster, with less memory!)
    • security auditing
    ...for a half year or a year. I don't need new features, I'm currently happy with the ones I have and I'd prefer the current features working securely, in a speedy fashion and mostly without bugs. This time period would also give enough time for extensions to mature more.

    Before someone jumps at my throat, it's just a description what I'd like to see, but of course its all up to the developers, they decide what to code and do with their time. It is just simple user feedback.
  • See Firefox is the most unstable program in common use [slashdot.org].

    The Firefox CPU hogging bug makes a computer unusable until all Firefox windows and tabs are closed. Basically, Firefox uses first maybe 10%, then maybe 20% of the CPU, and, as Firefox windows and tabs are opened and closed, continues taking more of the CPU time until Firefox is closed. This CPU usage is with NO Firefox activity, or any activity of any program.

    This bug is more than 3 years old. It is extremely difficult to characterize; no one has succeeded yet. Here are some clues:

    Somehow Thunderbird and Mozilla share this bug. Sometimes when Firefox is taking say, 94% of the CPU, and Firefox is closed completely, Thunderbird or Mozilla will begin using a lot of CPU time. Very weird, but it often happens.

    Firefox 1.5.0.1 is much worse than 1.5, which is worse than earlier versions. This suggests that there is some resource in Firefox that is being more overused as features are added.

    The CPU hogging bug continues unchanged when Firefox 1.5.0.1 is installed with a clean profile and no extensions.

    Too many mouse clicks too closely spaced will often increase Firefox's CPU usage, or sometimes cause it to crash.

    --
    Before, Saddam got Iraq oil profits & paid part to kill Iraqis. Now a few Americans share Iraq oil profits, & U.S. citizens pay to kill Iraqis. Improvement?
  • sounds good to me by ummit (Score:1) Tuesday February 14 2006, @06:13PM
  • seems snappier (Score:3, Informative)

    firefox's memory usage has always been a thorn in my side. I tend to average around 20 to 25 tabs open, usually while I'm running other ram hungry applications. Firefox generally was eating up about 200-250 megs of ram on my machine (and I've seen it go as high as 600 megs). After changing the browser.sessionhistory.max_total_viewers to 0 and running "top" firefox seems to be using about 46 megs of ram right now. It also doesn't feel particularly slower than it did before. I have a feeling that the benefit of caching so much was actually having a negative return after a certain point because the machine was so starved for ram.
    On a side note, if anyone is like me and looks in about:config for browser.sessionhistory.max_total_viewers and doesn't see it, you have to actually add the line. Right click and choose "new" then type in "browser.sessionhistory.max_total_viewers" and then 0 (or whatever you like).
  • Simple solution by vertinox (Score:2) Tuesday February 14 2006, @06:19PM
  • Huh? (Score:5, Insightful)

    by countach (534280) on Tuesday February 14 2006, @06:28PM (#14720459)
    Uh, using a lot of memory is not the same as a memory leak.
    • Re:Huh? by Keeper (Score:2) Wednesday February 15 2006, @02:54AM
  • Don't bug me (Score:5, Interesting)

    by joeytsai (49613) on Tuesday February 14 2006, @06:31PM (#14720478)
    I think this submission is confusing two points. First of all, is this really a memory leak? A program that uses a lot of memory is not necessarily a leaking program. A memory leak is a programmatic error where memory is allocated but never freed, even when there's no way to use that object again. As the program continues to allocate memory, the heap size of the process increases until eventually the OS terminates the process (eg., the OOMKiller). Actually, many applications you normally use leak memory - but as long as they don't waste a ridiculous amount of memory most people don't care, especially since most process lifetimes are relatively short (compared to a daemon process like apache), and after termination the OS reclaims all the program's memory, leaked or not.

    What is being described here sounds much more like a cache of recent pages, which in my opinion is perfectly sane for a browser. Sure, maybe the cache is a bit overzealous, but even if that's the case, just disable it - worse case scenario, you edit the source. But otherwise, this is definitely a feature - I can promise you it's much more programming effort to save old pages for a quick redraw than to free the old page and replace it with the new.

    So I guess the discussion here is, "is it right for firefox to use so much memory?" My answer is yes. It is not a memory leak, it seems like a very valid design decision. But if you disagree, old versions of firefox still work great (I still haven't upgraded myself).
  • Amazing! by Elladan (Score:2) Tuesday February 14 2006, @06:35PM
  • so what? by ShaneThePain (Score:1) Tuesday February 14 2006, @06:41PM
    • Re:so what? by rbarreira (Score:2) Tuesday February 14 2006, @07:08PM
    • Re:so what? by TheEvilOverlord (Score:1) Tuesday February 14 2006, @07:54PM
      • Re:so what? by TheEvilOverlord (Score:2) Wednesday February 15 2006, @06:39PM
      • 2 replies beneath your current threshold.
    • Re:so what? by fimion (Score:1) Tuesday February 14 2006, @08:38PM
    • Re:so what? by xtieburn (Score:1) Tuesday February 14 2006, @08:42PM
    • Re:so what? by thetaco82 (Score:1) Tuesday February 14 2006, @09:32PM
  • What if you have source code and change it? by WillAffleckUW (Score:1) Tuesday February 14 2006, @06:44PM
  • Close all tabs, still tons of RAM consumed by shodson (Score:2) Tuesday February 14 2006, @06:52PM
  • Firefox crashes when two browser windows are making synchronous XMLHttpRequests. I have experienced this under Linux - I have no idea whether it is the same under Windows. Basically under Lunux all Firefox windows are running in the same thread utilizing a scheme of cooperative multitasking.

    So far so good. The bug appears when two separate Firefox windows are making periodic synchronous XMLHttpRequest-s. When such a potentially lengthy task has to be executed synchronously, Firefox creates a new "nested" event queue. If two (or more) browser windows are doing it at the same time, new event queues are created all the time and eventually (within 5 minutes) the application core-dumps.

    I found this by recompiliging Firefox with debug information and debugging it. Even if my interpretation of what happens is not completely correct, the fact remains - a simple JavaScript can crash Firefox causing all open browse windows to be closed.

    The solution is to always use asynchronous XMLHttpRequest (which is a better practice anyway) and to hope that the same problem doesn't appear in other places. Still, it is troublesome.

  • two words: "totally" "wrong" by Mini-Geek (Score:2) Tuesday February 14 2006, @07:40PM
  • It's not a secret by whitehatlurker (Score:2) Tuesday February 14 2006, @07:59PM
  • I guess... by sabit666 (Score:1) Tuesday February 14 2006, @08:00PM
  • Well by lord_sarpedon (Score:1) Tuesday February 14 2006, @08:07PM
  • Ignoring the bifurcations.. by DeadPrez (Score:2) Tuesday February 14 2006, @08:07PM
  • Firefox developers don't "get it" (Score:5, Insightful)

    by Vellmont (569020) on Tuesday February 14 2006, @08:10PM (#14721149)
    Memory isn't an unlimited resource you just hoard whenever you think you need it. Right now my instance of firefox is taking up 128 megs! I've seen it up to 256 megs before. This is just simply insane. I've seen people who's computer performance has gone down the tubes because firefox is taking up all the memory (and these are machines with 512 megs of memory, not exactly tiny). What I'd like to convey to the firefox devs is this: Your application isn't the only one running on the system. Play nice and don't be a hog.

    With the number of people complaining about this (and the number of people that don't even KNOW to complain) isn't it a safe bet that you've made a mistake in the amount of cached pages?
  • Debian's/Ubuntu's FireFox by Peaker (Score:2) Tuesday February 14 2006, @08:20PM
  • See Mozilla bug 286795 by lloydwood (Score:1) Tuesday February 14 2006, @08:29PM
  • Simple fix by Cryolithic (Score:2) Tuesday February 14 2006, @08:30PM
  • Guess I should have previewed by Cryolithic (Score:1) Tuesday February 14 2006, @08:34PM
  • Doesn't every browser store a cache? by HaMMeReD3 (Score:1) Tuesday February 14 2006, @08:42PM
  • Performance by Isotopian (Score:1) Tuesday February 14 2006, @08:46PM
    • 1 reply beneath your current threshold.
  • Heh by TheLink (Score:2) Tuesday February 14 2006, @08:56PM
  • bfd? by GeorgeMcBay (Score:1) Tuesday February 14 2006, @09:01PM
    • Re:bfd? (Score:5, Insightful)

      by Sigma 7 (266129) on Tuesday February 14 2006, @09:29PM (#14721623)
      Virtual memory, look into it!


      Virtual memory is not a carte blanche for memory hogging. As you should know, memory hogging will result in degraded performance.

      Assuming that users have unlimited resources is exactly how Mozilla is barely usable on Windows 95-ME - especially when you have Slashdot Moderator access.

      Who cares if Firefox or any app is a bit of a memory hog???

      As long as it is just using the memory as cache space and not accessing the memory randomly, it'll be paged out into virtual memory as needed.


      In an ideal situation, that would be correct.

      However, the operating system does not know which memory is currenly "in use" and which ones are "in cache" - in fact, it's quite easy for an "in use" to be physically sandwiched between two "in cache" entries. Because of this, you will have a sudden loading time if you do plenty of other tasks in the background and suddenly switch back to Mozilla.

      Small applications, being small, do not generally have to wait 1/2 seconds to recover from being pages in or out. Since Mozilla allocates the cache in memory, it will have to wait those two seconds.

      assuming you're using an OS with decent vmem support.


      An OS with decent vmem support would allow you to map files to memory. This results in no swapping at all - only writing perodic output to the hard drive, and loading the file into memory as required. If another application needs more memory, the memory map is discarded with no need to write the contents of memory.

      An application that doesn't exploit the usage of memory maps is as good as an OS with shoddy vmem support. (Of course, it can simply use it's disk cache for the same effect.)

      [ Parent ]
      • Re:bfd? by GeorgeMcBay (Score:2) Wednesday February 15 2006, @12:16AM
  • Doesn't this just seem silly? (Score:3, Insightful)

    by robertjw (728654) on Tuesday February 14 2006, @09:02PM (#14721451)
    (http://www.emarketingpartner.com/)
    The cache feature is nice, but why distribute it out to every tab? If I have 20 tabs open I'm not going to be constantly clicking the back button on each of them. Why not clear the cache on tabs that haven't been accessed recently and only keep cache on tabs actively being used. Often when I open new tabs I just want to be able to quickly access that page, or use it as a temporary bookmark - not navigate back through the path that got me there.
  • No freeing memory == memory leak by Guspaz (Score:2) Tuesday February 14 2006, @09:09PM
  • Not quite the way I wanted it fixed... by vanyel (Score:2) Tuesday February 14 2006, @09:10PM
  • Wait a sec by ben_1432 (Score:1) Tuesday February 14 2006, @09:15PM
  • Faster??? by bubkus_jones (Score:1) Tuesday February 14 2006, @09:16PM
  • feature by akhomerun (Score:2) Tuesday February 14 2006, @09:17PM
    • Re:feature by akhomerun (Score:2) Tuesday February 14 2006, @09:20PM
  • Heuer's Razor by cs (Score:1) Tuesday February 14 2006, @09:19PM
  • Doesn't seem to work by The Analog Kid (Score:2) Tuesday February 14 2006, @09:29PM
  • Shouldnt it care about the RAM a bit more? by xtieburn (Score:1) Tuesday February 14 2006, @09:29PM
  • There really is only one solution by gamepro (Score:1) Tuesday February 14 2006, @09:30PM
  • They're blowing smoke up you're ass by Theovon (Score:2) Tuesday February 14 2006, @09:41PM
  • If it's a feature.... by happymedium (Score:2) Tuesday February 14 2006, @09:47PM
  • R-RTFA (Score:4, Informative)

    by Chris Snook (872473) on Tuesday February 14 2006, @09:51PM (#14721716)
    The article has been corrected. Note that the maximum number of cached pages, regardless of the number of tabs, defaults to 8, and that's only if you have at least 1 GB of RAM. RTFSC:

    http://lxr.mozilla.org/seamonkey/source/docshell/s history/src/nsSHistory.cpp#161 [mozilla.org]

    If you're unhappy with the memory usage with 50 tabs open, I advise the following workaround:

    DON'T DO THAT.
    • Re:R-RTFA by Jugalator (Score:2) Wednesday February 15 2006, @02:43AM
  • Rewritting history. (Score:5, Informative)

    by SeaFox (739806) on Tuesday February 14 2006, @09:58PM (#14721749)
    Firefox 1.5 implements a Back-Forward cache that retains the rendered document for the last five session history entries for each tab. This is a lot of data. If you have a lot of tabs, Firefox's memory usage can climb dramatically. It's a trade-off. What you get out of it is faster performance as you navigate the web.

    The only problem is there were bugs filed for memory leaks long before Firefox 1.5 and the Back-Forward cache were implemented. Maybe this feature does contribute to Firefox's large memory footprint, but to say that this feature is the only reason and that there are no leaks is simply false.
  • How about a way to turn it off? by JourneyExpertApe (Score:2) Tuesday February 14 2006, @10:33PM
    • 1 reply beneath your current threshold.
  • POST data? (Score:3, Interesting)

    by Quixote (154172) * on Tuesday February 14 2006, @10:46PM (#14721972)
    (http://slashdot.org/ | Last Journal: Wednesday April 16 2003, @07:07AM)
    If Firefox is caching these pages, why doesn't it cache POST results? When I hit back to go back to a page obtained via POST, FF refuses to show it to me, asking me to either cancel the action or resubmit the form. JUST SHOW ME THE GODDAMMN PAGE, DAMMIT!. Once the page lands in my machine, regardless of how I obtained it (i.e. via GET, POST or whatever), then just show it, or at the very least give me the option of seeing the possibly expired page. Let it be my decision.
    • Re:POST data? by WuphonsReach (Score:2) Thursday February 16 2006, @11:34AM
  • Crap by 4D6963 (Score:1) Tuesday February 14 2006, @10:59PM
    • 1 reply beneath your current threshold.
  • Too bad this is BS by pyite69 (Score:2) Tuesday February 14 2006, @11:32PM
  • is it a "memory leak" then? by Pr0xY (Score:2) Tuesday February 14 2006, @11:45PM
  • Memory leak? How about CPU LEAK ???! by aqk (Score:1) Wednesday February 15 2006, @12:51AM
  • This explanation makes no sense by Siguy (Score:2) Wednesday February 15 2006, @01:05AM
  • I'm definitely insane (Score:3, Insightful)

    by try_anything (880404) on Wednesday February 15 2006, @01:52AM (#14722623)
    Every time I close all the tabs in my browser session except two or three, then check a few hours later and see that Firefox is sluggish and hogging a few hundred megabytes, I go to the police and ask them to take me into protective custody. I'm obviously a danger to myself and others. When I'm not responsible enough to seek psychiatric help, I just stare at my monitor and tell myself, "You only see three tabs there, but that's because you're crazy. You still have all those dozens of porn tabs open. You just can't see them because you went blind masturbating."

    Seriously, what's with all the song and dance? Firefox obviously has at least one problem, probably several, that leads to bad performance for many users, under certain circumstances. Call it a UI problem, call it a documentation problem, I don't care, just call it a problem. Don't call it a feature or a misunderstanding. Don't pick a feature that can't account for many of the reported problems and say, "Aha! This is THE Firefox memory leak that's bothering everyone. See? It's a feature!" The denials and talk-arounds on this issue are what you would expect from a political party, not an open-source software project.

    Of course, I only know all this because I use Firefox. It's the best. The memory problems would only be a minor annoyance if I didn't have to constantly read about how I'm crazy or stupid.
  • by Arimus (198136) on Wednesday February 15 2006, @03:37AM (#14722921)
    First off I like Firefox and its my primary browser of choice. HOWEVER this calling a bug a feature doesn't half remind me of a certain other company I could mention (and several Dilbert cartoons).

    If this feature is for my benifit then let me decide whether to use it or not. Apart from that it does not explain why when I leave firefox idle with only one window open on a simple HTML page over time my memory useage goes up...

    Stop hiding behind feable excuses and actually work on reducing the footprint firefox uses... FF is suposed to be a lightweight browser alternative to the usual browser bloatware - it is failing at the moment (rather like my spelling ;) ).
  • Are you confused or stupid? by Anonymous Coward (Score:2) Wednesday February 15 2006, @03:37AM
  • by klui (457783) on Wednesday February 15 2006, @04:33AM (#14723049)
    I find that if I set browser.sessionhistory.max_total_viewers to 2 it uses less memory if it's left at the default (I have 1GB RAM). If I use Fasterfox's Clear Cache function, it compacts the memory usage even more. There is still some leakage but not as bad as the default -1.
  • It may be a feature, but it's still undesirable by OneSmartFellow (Score:2) Wednesday February 15 2006, @04:37AM
  • Competition (Score:3, Interesting)

    by Britz (170620) on Wednesday February 15 2006, @04:43AM (#14723073)
    First everyone complains that they should be as fast as possible to compete with IE, which is pretty fast.

    When they do it the get slapped for using too much resources?

    But I see a good point. I also would like to see new developement halted for some time to catch bugs and security problems. This would also help plugin developers to catch up. New features could be developed in plugins anyways.
  • garbage colection by wwmedia (Score:1) Wednesday February 15 2006, @05:12AM
  • Per Session, not per Tab (Score:3, Insightful)

    by dzfoo (772245) on Wednesday February 15 2006, @05:53AM (#14723229)
    Its a non-issue. As explained on a note at the end of the article, its a per session setting, not per tab, so the entire article misrepresented the "feature".

    "Edit: In the comments, Boris and David pointed out that I misread the code, and that this is a global preference so that there are no more than 8 cached pages for the entire session, not per tab. My initial posting had claimed that it was per-tab. Oops!"

    If Firefox has memory leaks (and I think it does), this is not what is causing it. If it were, however, per tab, as the article originally claimed, then it would have been a problem, because the more tabs you open, the memory usage increases at an alarming rate, if it has to keep up to 8 history pages cached.

    Nothing to see here. Move along.

              -dZ.
  • I just recently switched to Konqueror by Entropy (Score:1) Wednesday February 15 2006, @06:34AM
  • Generous for open source...? by Sithgunner (Score:1) Wednesday February 15 2006, @07:13AM
  • Apart from that... by Cinquero (Score:1) Wednesday February 15 2006, @08:20AM
  • Uhh Firefox isn't the only one... by PaisteUser (Score:1) Wednesday February 15 2006, @08:43AM
  • Hardly an issue.. by trintron (Score:1) Wednesday February 15 2006, @09:14AM
  • Close the Browser! by rdebath (Score:1) Wednesday February 15 2006, @09:36AM
  • anyone know what affect by petermgreen (Score:2) Wednesday February 15 2006, @10:29AM
  • "Memory Leak"?!? by PhYrE2k2 (Score:2) Wednesday February 15 2006, @10:54AM
  • Lets try this... by DoctorDyna (Score:1) Wednesday February 15 2006, @01:53PM
  • WTF.. by Shifuimam (Score:1) Wednesday February 15 2006, @03:14PM
  • of course by ZiZe (Score:1) Wednesday February 15 2006, @06:45PM
  • Just for the record... by Spy der Mann (Score:1) Tuesday February 14 2006, @05:53PM
  • Re:Ready... Aim... by vsprintf (Score:1) Tuesday February 14 2006, @08:19PM
  • Re:Firefox performance slowed to a crawl by HeroreV (Score:1) Tuesday February 14 2006, @10:20PM
  • by cruachan (113813) on Wednesday February 15 2006, @02:56AM (#14722801)
    Give up and use Opera. Firefox is profoundly broken in combination with (a) memory leak being discussed and (b) memory leaks in plugins. The second seems to even include Flash, where some flash pages appear to be cache in active state and sit there using CPU cycles as well as memory.

    I think we've no got to the state where Firefox can be seen as a nice try, but no cigar. Opera on the other hand just works - and increadibly it's quick and lean too.

    I've no connection with Opera, just like many I've been through the "Dump IE, Use Firefox, Think Firefox is wonderful, Find Firefox's dreadful memory/cpu cycle leaks, Dump Firefox" cycle!
    [ Parent ]
  • 21 replies beneath your current threshold.
(1) | 2