Slashdot Mirror


Mozilla MemShrink Set To Fix Firefox Memory

darthcamaro writes "If you're like a lot of Firefox 4 users out there, you've probably noticed that Firefox has a serious memory problem — it uses more than it really should. At long last, Mozilla developers are finally set to take this issue seriously with a dedicated team called MemShrink that are focused on the problem. 'It's pretty clear by now that this is a much bigger problem than any one person can likely tackle,' Mozilla Developer Johnny Stenback said."

7 of 375 comments (clear)

  1. Re:bound to fail by MrEricSir · · Score: 5, Funny

    64 bits is only 8 bytes. An unsigned 64-bit number can take Firefox all the way up to version 18,446,744,073,709,551,615.

    So that should take them at least until through next Thursday.

    --
    There's no -1 for "I don't get it."
  2. Re:And probably too big... by maxume · · Score: 5, Informative

    My experience has been that both leaks and overall memory use have gone down between 3.0 and 4.0.

    At the moment, Firefox is at about 375 megabytes, with 16 tabs open. It has been open for 3 weeks. I do have browser.sessionhistory.max_total_viewers set to 3 and the anti-malware databases disabled though.

    --
    Nerd rage is the funniest rage.
  3. Re:All browsers are consuming more memory. by SimonTheSoundMan · · Score: 5, Informative

    A useful new feature in latest Nightly versions from Mozilla is about:memory. It gives you a full tree view of where the memory is being used. Of my 360MB which the browser is currently using, 101MB is JS, 46MB is storage (you back button and memory cache), 70MB on "heap-unclassified" whatever that is. JS seems to be the biggest consumer of memory.

  4. Yay by OverlordQ · · Score: 5, Insightful

    At long last, Mozilla developers are finally set to take this issue seriously

    Yay, it only took 5 years of bitching for them to actually look into it instead of blaming addons or your profile.

    --
    Your hair look like poop, Bob! - Wanker.
  5. Re:Problem of perception? by Anonymous Coward · · Score: 5, Insightful

    Using ram is 'good' and 'superfetch' are good too huh?

    How did that info get into memory. Oh thats right by me waiting for it to load from either the internet or from disk.

    Back when I used vista turning superfetch off was the #1 way to make the computer usable. Superfetch was too aggressive in loading things. Turn computer on wait 15 mins (no kidding) before I could use the start button. It was even so aggressive it would keep memory full at all times. Meaning as programs freed and used memory the disk was thrashing ALL the time. It was noticeably faster and measurable too (I measured it many times thinking guys like you must be right). Win 7 is a whole different story (it actually works).

    As for using too much memory. Using less does mean better performance. *IF* done right. But how much of that information in this case is just 'leaks'? A leak is never going to be used. Meaning windows needs to keep track of it and page it out a some point (meaning less performance at some point).

    To bury your head in the sand and say using memory is bad is stupid. But so is using it all up is good. But think about this I have open 1 tab right now to type this in. It is using 250 meg (and that is just what is paged in meaning something in the program touched it). WTF is it doing... That is a seriously crazy amount of memory to be using to have this page open which about 30k. That is some serious overhead there. From this old 80s/90s programmer I look at that and think wtf dudes. You KNOW you can do better than that.

  6. Re:Problem of perception? by QuoteMstr · · Score: 5, Informative

    If it were possible for programs to allocate caches that work like the filesystem cache, where old items get discarded automatically to make room for anything more important, then this would make sense

    The system you describe is called malloc()!

    In a system with a unified buffer cache (essentially, every OS in wide use except OpenBSD), it makes little difference whether a page of memory comes from a private memory allocation (e.g., a heap allocation), a memory-mapped file, or the OS's disk cache. When a process needs a page not already present in memory, the kernel's memory manager tries to find an unused page. If one is available, it hands it to the program that requested memory.

    Otherwise, it looks for an in-use page, saves its contents, and hands the just-freed page to the program requesting memory. If that page is "dirty" --- i.e., it's backed by a file and somebody's written to that part of the file, or it's a private allocation backed by the page file --- the memory manager writes the page out to disk first. If the page isn't dirty, the memory manager can just discard its contents because it knows it can reconstruct it by reading back the original file.

    When the memory manager has to go to disk to satisfy a request for a new page, it's called a hard fault. The mission of the memory manager is to reduce the number of hard faults, because hard faults are slow. The fewer hard faults you have, the less time will be spent waiting for the disk, and the faster your system will run.

    The most important part of the memory manager is page replacement: i.e., how the memory chooses what page to evict in order to satisfy a memory allocation request. Most systems use an approximation of LRU (i.e., least recently used), throwing out pages that haven't been accessed in a while. It doesn't usually matter where a page came from. The only important factor is how recently it was accessed.

    So, you can see that there's no difference between a program mapping a file into memory and modifying it, reading and writing it using file APIs, and just manipulating an equal amount of information in buffers created with malloc. To the kernel, all memory is made up of pages.

    The "go away for a while" problem isn't caused by any particular memory strategy. It's an artifact of the memory manager's LRU approach. How does it know that the pages corresponding to Firefox are going to be used again? If some other program needs those pages, the older ones will be discarded. There is nothing applications can do.

    Instead, the OS itself has to be tweaked to preserve interactivity. Sometimes the memory manager will prefer disk cache pages to malloc-backed ones. Sometimes (e.g., for Windows SuperFetch) the OS will try to identify pages belonging to activate applications and try harder to keep those in memory. Some systems favor keeping executable pages over private allocations. You can tweak the page replacement algorithm, but the basic idea, that all memory is made up of pages subject to the same management scheme, applies.

    Ultimately, it's ridiculous to hear people talk about programs "keeping things in memory" like we were still dealing with DOS 6 and OS 9. The actual situation is a lot more subtle, and silly memory counters don't even come close to giving you a good picture of what's actually going on.

    In short, don't worry about fine-tuning what's "in memory". Don't change behavior based on total amount of memory in the system. Operating systems (OpenBSD aside) ALREADY DO THAT. Just let the memory manager do its job, and give it enough information (via interactivity information, memory priority, etc.) to do its job properly. Don't try to hack around problems at the wrong layers.

  7. Re:Problem of perception? by arth1 · · Score: 5, Insightful

    it's not designed to be open for a week straight.

    Then it needs to be redesigned.
    I do not need a server to become sluggish because a user left on vacation with Firefox still running with a detached display.
    And I do not want to have to close my munin/bigbrother/mrtg windows running on the wall monitor. It should keep running.

    Remember how we ridiculed Microsoft for Windows 95 not being able to run more than a few days without a reboot? Well, it's time we laugh at the idiotic Firefox devs who repeat the same mistakes and invalid assumptions.

    Because of the severe bloat and WTF assumptions made by the newer generation of Firefox devs, I've started using other browsers more and more. Like Midori ("it's not easy being green").