Slashdot Mirror


Reducing Firefox's Memory Use

An anonymous reader writes "Many people have complained about Firefox's memory use. Federico Mena-Quintero has a proposal for reducing the amount of memory used to store images, which, in his proof of concept code, 'reduced the cumulative memory usage... by a factor of 5.5.'."

110 comments

  1. Easier solution by plover · · Score: 4, Insightful
    Buy more memory. It seems to be the rest of the industry's answer to resource hogging software. Look at all the bloatware out there: XML, JVMs, .NET, etc. The rest of the world is building for 1GB boxes, so who cares how efficient their code is anymore?

    Coming from me, this is sarcasm, but it's a depressingly prevalent real attitude in the industry.

    --
    John
    1. Re:Easier solution by eggstasy · · Score: 2, Interesting

      With CPU development practically stagnating, but RAM and HD storage still growing fast, it also strikes me as a pretty good solution. I wouldn't want to instance that CPU-hogging old JPEG algorithm 50 times just because I hit the back button.
      There's always a tradeoff between memory use and CPU comsumption. If it's simple to do and has enough impact, maybe they should let the users decide?
      Or even automatically configure it depending on the user's hardware.

    2. Re:Easier solution by obi · · Score: 2, Interesting

      it's not just the amount of space it takes in RAM and HD, but also the amount of time it takes to transport something that's 5.5x bigger. Have you seen hard drives become 5.5x faster recently? Or even RAM?

      At the same time, rendering/decompressing an image might be quite self-contained, and running 50 self-contained instances of that CPU-hogging old JPEG algorithm might parallellize quite easily, so would scale with the current trends in CPU development (more parallel - just throw more chips/cores/DSPs/GPUs at it).

      Just imagine trying to take advantage of graphics hardware that can decode JPEGs in hardware.

    3. Re:Easier solution by GigsVT · · Score: 3, Insightful

      With CPU development practically stagnating, but RAM and HD storage still growing fast

      What?

      I could believe HD, but RAM sizes have not kept up at all. You might have gotten a system with 128 megs with a 20 gig hard disk with a CPU running 800 mhz a few years ago. These days you get a system generally with something like 512 megs and 200 gigs storage running 3Ghz. Also RAM prices have not dropped all that much. 512megs of DDR2 is over $200.

      Yes, CPU speeds have stagnated in the last year or so, only growing by 10-20%, but RAM hasn't advanced all that much in the size department.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
    4. Re:Easier solution by Jeff+DeMaagd · · Score: 2, Informative

      At first, I thought so, but I just looked at my memory usage and Firefox is the top hog, beating the next two with more combined memory use. I don't mind a program taking 50MB, but it's at 116MB right now.

    5. Re:Easier solution by Guspaz · · Score: 5, Informative

      Firefox (on Windows) can and will suck up an infinite amount of memory. This is because under some circumstances (Well, always, at least for me and many other users) it does NOT remove the uncompressed images from memory when a tab is closed.

      If I am opening and closing a lot of image-heavy tabs, after a while, my firefox instance is sucking up 800MB of system memory, and the ONLY way to free it is to restart firefox.

      I don't care about firefox's memory usage with compressed versus uncompressed. If I'll get more speed with 90MB of uncompressed images, go for it. What I do have a problem with is how it doesn't bother to remove raw images that are no longer needed. Essentially, it is a really bad memory leak that they haven't fixed for ages.

      As for reducing actual memory usage, a hybrid solution is best. At the very least all images on other tabs should remain compressed, and then decompressed when switching to that tab, going back to the compressed images from the old tab (Disk cache them, or keep both compressed and uncompressed in memory).

      In addition, you can probably do smart-cacheing on images on the current tab. As the article author mentioned, keep uncompressed copies of only images near the current viewport. Another solution might be to store everything as compressed, even in the current tab, and modify the rendering engine so that images are drawn asynchronously. A 100ms delay while scrolling will cause noticeable hitching, but if you draw the rest of that page and throw in the image 100ms later, the user will have a much smoother experience. They can keep scrolling while the image is loaded in.

    6. Re:Easier solution by Jeff+DeMaagd · · Score: 1

      I would suggest that the expansion in RAM sizes available to new computers is in part due to cost cutting to minimize the unnecessary expense and the fact that not many users need that much RAM because most programs have been needing it.

      I managed to score an off-lease computer for dirt cheap decked out to 4GB of RAM, then realized that I have absolutely no need or use for that much memory. On a Windows 2000 computer, I rarely use more than 500MB.

    7. Re:Easier solution by molnarcs · · Score: 1

      Firefox alone, with only a few tabs open, can consume as much ram as xorg + kde (including amarok, kmail, and everything that loads up at startup on my box) + konqueror. Bloatware or what?

    8. Re:Easier solution by Anonymous Coward · · Score: 0

      That's because windows is kind of dumb about making use of lots of RAM, because it's built on the assumption that RAM is scarce rather than plentiful.

      In a memory rich VM system, there's no reason to ever take a lot of things out of RAM; if an app was loaded once it'll probably be loaded again.

      In point of fact, there's no reason not to fill in ram with data that hasn't even been asked for yet just in case you need it latter (provided you take reasonable precautions not to use up all your disk bandwidth caching stuff into RAM when user processes are trying to use the disk). If you have 4GB of unused ram, there's no reason the OS shouldn't use it all as a gigantic disk cache for reading commonly used files (as opposed to the more write-focused little 8-16MB of cache ram on the HDD), and just overwrite pages of the cache whenever apps need memory.

    9. Re:Easier solution by plover · · Score: 3, Funny

      You call it a leak. They call it a cache. Semantics, really. :-)

      --
      John
    10. Re:Easier solution by toddbu · · Score: 1
      The other problem is that you'll still have to periodically close out the browser to free all the memory that's in use, meaning that you have to reload all those pages that you have open in various tabs. Forgive me for comparing Firefox to Windows, but I have to effectively "reboot" Firefox from time to time in order to get all that memory back. It makes it harder to send the message that Linux doesn't suffer from the same problems that Windows does when you have to restart the browser.

      That being said, I think that Firefox is still the best browser on the planet.

      --
      If you don't want crime to pay, let the government run it.
    11. Re:Easier solution by Pig+Hogger · · Score: 1
      The other problem is that you'll still have to periodically close out the browser to free all the memory that's in use, meaning that you have to reload all those pages that you have open in various tabs. Forgive me for comparing Firefox to Windows, but I have to effectively "reboot" Firefox from time to time in order to get all that memory back.
      It's not only that. Firefox will periodically freeze in it's tracks for about 1 minute; CPU usage climbs to 70-80% while it's doing god knows what.
    12. Re:Easier solution by Anonymous Coward · · Score: 0

      512megs of DDR2 is over $200?

      huh?

      I think you put an extra zero on that price. You can get 512MB of Kingston DDR2 533 RAM for $27.85 on Newegg...

    13. Re:Easier solution by Anonymous Coward · · Score: 0

      Oops, copied the wrong link, that was an even cheaper off-brand.

        here's the kingston.

    14. Re:Easier solution by Halfbaked+Plan · · Score: 1

      It makes it harder to send the message that Linux doesn't suffer from the same problems that Windows does when you have to restart the browser.

      That it does. But Linux isn't any better than Windows when running an equivalent browser. Mozilla on Windows and Mozilla on Linux is about the same in almost all regards.

      So the important thing is to point out that there are plenty of other advantages in running Linux.

      --
      resigned
    15. Re:Easier solution by aconbere · · Score: 1

      I actualy don't see any memory issues in Firefox in Linux whereas I deffinantly experience these glitches on the windows machines I have to use at work. They are running equivelent machines, I just never see firefox memory or cpu use climb while on Linux.

      ~Anders

    16. Re:Easier solution by GigsVT · · Score: 1

      I was just going on the first thing I saw on crucial.com, Ballistix 240-pin DIMM, 512MB DDR2 PC2-8000 5-5-5-15 UNBUFFERED NON-ECC DDR2-1000 2.2V 64Meg x 64, $210.

      I see now that is the highest end stuff, but what you linked to was 256megs. Looks like a more realistic price is somewhere in the middle, $80 or $90.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
    17. Re:Easier solution by An+Onerous+Coward · · Score: 1

      If the program knows how to reference the memory again if needed, then it's not technically a memory leak. So I guess what he's complaining about is "inefficient caching of tiles." Which is no small thing, I guess.

      --

      You want the truthiness? You can't handle the truthiness!

    18. Re:Easier solution by Kris_J · · Score: 1
      It's not only that. Firefox will periodically freeze in it's tracks for about 1 minute; CPU usage climbs to 70-80% while it's doing god knows what.
      The A9 and Google toolbars used to cause this whenever I hit an https page -- check for that.
    19. Re:Easier solution by Pig+Hogger · · Score: 1

      Got none of those, but I suspect the "Web Developper" could be the culprit...

    20. Re:Easier solution by Curtman · · Score: 1

      Try turning off "browser.cache.memory.enable", in about:config, and see what the usage is. I bet that's the majority of it, and 116M is just fine with me. If memory is tight, it might be a good thing to sacrifice though.

    21. Re:Easier solution by jlarocco · · Score: 2, Insightful

      Good idea. I don't use Firefox, but that approach will ensure that next time I think about switching browsers, I'll have one less option to consider.

    22. Re:Easier solution by rookworm · · Score: 2, Funny

      If you're viewing THAT many images, the Easiest Solution in this case would be to quit looking at all that goddamned porn!

      --
      The toad can't burp - and for some reason can't fart either, so it swells up and eventually explodes. --Anonymous Coward
    23. Re:Easier solution by jonadab · · Score: 3, Interesting

      > What I do have a problem with is how it doesn't bother to remove raw images that are no longer
      > needed. Essentially, it is a really bad memory leak that they haven't fixed for ages.

      This is *partly* due to the way memory allocation and freeing work at the system call level. In a nutshell, memory that you free does not actually become free for other programs to use until your process exits. (As bad as this sounds, it's preferable to the situation wherein the system doesn't know what process owns the memory, so if an app has a leak the only way to reclaim it is to restart the whole system.) I am not sure which platforms have this (wait until the app exits) behavior, but I think it might be fairly common, although on some systems the not-really-free memory may be given to the *same* process again, next time it requests more memory, and in that case it shouldn't grow infinitely, as it would be only *other* processes that can't use it. Still, it's annoying that once you've loaded up too much at once and grown the process' memory usage to a large figure, the only way to reclaim that for other apps is to exit the process -- closing the document that caused all the usage won't do it. I *think* this is the behavior I see on Ubuntu, e.g., once I've had a really complex SVG image open in Inkscape (or a big document in OpenOffice with a lot of frames and especially images in it), and I then open a smaller, simpler image (or document) and close the big one, the memory doesn't get freed until I close Inkscape. However, if I've had a big document open, which I've closed, and then I open another big document, the memory usage doesn't go up any worse (unless the second document is bigger or more complex than the first one, of course), so it appears the same process is handed that same memory again that it freed earlier, even though another process can't have it.

      I *suspect* the same is true on Win NT/2K/XP, although it's harder to tell there, due to the lack of facilities such as panel applets and good process management tools. There's the mem command, but I haven't spent a lot of time on tracking memory usage that way. On the other hand, part of the reason I haven't spent time figuring it out is because memory that's not in usage any more on Windows systems usually ends up just growing the swapfile automatically, which is really not such a big deal if you've got plenty of hard drive space. I *mostly* like the way Linux handles virtual memory better than Windows (in particular, it (since circa 2.4, or maybe it was in 2.2) seems to do a quite good job of knowing what to swap out or not to keep thrashing to a minimum), but I do like the auto-allocation that Windows does.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    24. Re:Easier solution by Breakfast+Pants · · Score: 1

      Bah, it is just cache. If I have the memory available why not use it? Unfortunately Firefox isn't at a Kernel level and can't know if perhaps some portion of the memory would be better spent overall if it were used on caching the local I/O for example.

      --

      --

      WHO ATE MY BREAKFAST PANTS?
    25. Re:Easier solution by Breakfast+Pants · · Score: 1

      When you say 3Ghz just be aware that that is the "Pentium 4" Ghz, which isn't the same as "Pentium III" Ghz. We really haven't come as far as you say.

      --

      --

      WHO ATE MY BREAKFAST PANTS?
    26. Re:Easier solution by nxtw · · Score: 1
      What are you talking about? You can get 512MB DDR2 for less than $40, including name brands, at Newegg.

      It's actually cheaper than DDR or SDRAM.

      Even 200-pin DDR2 SODIMMs are reasonably priced.

    27. Re:Easier solution by Guspaz · · Score: 1

      Firefox doesn't re-use the memory though. It just keeps going up until it either consumes all system memory or it is restarted.

      As mentioned in other posts, it may not be a memory leak if it can still reference unused bitmaps, but it doesn't seem to be ever removing the old bitmaps from the cache.

      My solution to this so far has been SessionSaver; I can just terminate Firefox and re-open it. All my tabs and sessions are exactly like before I closed it, except memory usage is back to normal.

    28. Re:Easier solution by Anonymous Coward · · Score: 0

      A default desktop windows installation actively and aggresively pushes background apps to swap, even if there is no memory shortage - go figure ....

    29. Re:Easier solution by GuyWithLag · · Score: 1

      This is a relic from the C/C++ language, having to do with memory fragmentation and non-relocatablity of objects.

    30. Re:Easier solution by at_18 · · Score: 1

      This is *partly* due to the way memory allocation and freeing work at the system call level. In a nutshell, memory that you free does not actually become free for other programs to use until your process exits. (As bad as this sounds, it's preferable to the situation wherein the system doesn't know what process owns the memory, so if an app has a leak the only way to reclaim it is to restart the whole system.)

      Are you sure? Leaked memory is memory which is still allocated to the leaking process, so you can safely allocate all freed memory to other processes. And when the leaking process exits, all memory is given back. No need for reboots.

    31. Re:Easier solution by Anonymous Coward · · Score: 0

      This is a relic from the C/C++ language, having to do with memory fragmentation and non-relocatablity of objects.

      And those new fangled Garbage Collection languages that haver their VMs witten in C++, and their heaps allocated using C++ allocators. Sure, they can relocate the objects inside those heaps, but once they get large... they tend to stay large.

    32. Re:Easier solution by ScrewMaster · · Score: 1

      You forgot to mention Windows and KDE.

      Seriously, the tendency is to think, "Well, our target market has at least 256 Mb of memory and a 1 Ghz. CPU, so there's plenty of room and no need to optimize". It's easy to start thinking that way, and I suppose exponentially increasing memory demands are what drove manufacturers to keep lowering the cost-per-bit. The problem is that once multitasking operating systems became the rule, an application developer could no longer depend upon having all of a machine's resources to himself, or even a significant fraction. There's still good reason to code efficiently, but nobody seems to want to make the investment. It's just easier to shift the burden of wasteful code onto the users.

      But I will say that when I'm evaluating software, I appreciate the occasional well-written gem that I come across, amidst all the bloatware.

      --
      The higher the technology, the sharper that two-edged sword.
    33. Re:Easier solution by mallie_mcg · · Score: 1

      The other problem is that you'll still have to periodically close out the browser to free all the memory that's in use, meaning that you have to reload all those pages that you have open in various tabs. Forgive me for comparing Firefox to Windows, but I have to effectively "reboot" Firefox from time to time in order to get all that memory back. It makes it harder to send the message that Linux doesn't suffer from the same problems that Windows does when you have to restart the browser.

      Is that because we are treating the browser in a different fasion to previously. To stay with the windows theme, I find that I too have to periodically close or quit firefox on a semi regular basis, but I am often running 4 windows each with 9-20 tabs open, with various history states that it seems to remember quite well. Take IE for example - (as far as my current understanding of 6.0) it instances a new process for each IE window that is open (meaning that force killing a window will not cause all IE windows to close) which means when you close a window its memory is freed, it no longer keeps the full history of pages viewed as mozilla/firefox tabs do.

      I do think that this will be an issue that microsoft will also find - typical memory usage patterns with their tabbed IE 7 will likely see the same issues that firefox has today. (Unless they do something along the lines of treating the "main" IE window as a basic container and instance a new IE for each tab or something, but hell I have nfi what will happen) (disclaimer - i dont use IE for anything other than emergency checking of pages that I "trust").

      Memory usage has to be viewed as a function of how much data is being read/accessed/used/stored. Yes mozilla/firefox is a pig as far as memory is concerned and closing a tab does not always seem to free the amount of memory that it uses, I hope that something gets looked at in this regard without slowing the interface down.

      Admittedly my solution to my firefox woes was to install memory, because the occasional pauses when windows decided to poke the on disk VM was irritating, and with 2G firefox can stay open for weeks at a time, I do notice running on a machine (work) that only has 1G. However, I would not like to see CPU intensive processing that adds any form of interface lag to firefox to be developed, it would be a negative experience for myself.

      --


      Do the following really mean anything? SCSA MCP CCSA CCNA
      --I'm not actually after an answer!
    34. Re:Easier solution by evilneko · · Score: 1

      You know, I never have to do that with Mozilla. In fact, 99% of the problems I see Firefox users complain about, I never experience with Mozilla. Hell, I leave Mozilla open for days on end, never bothering to close it when I go to work/sleep/eat/whatever. And that's on Windows, too--my linux box is too slow to tolerably run a gui (though lately, doing rather well with enlightenment, might have to try again..), in case you're wondering.

      Glad I switched back to Mozilla after Firebird...

      --
      Slashdot - where to disagree, is to be a troll
    35. Re:Easier solution by toddbu · · Score: 1
      I understand your point, but how about something as simple as a "cleanup memory" button. I too often have several tabs open (4 instances right now with 24 tabs) but most of those tabs will sit idle most of the time, like my PHP/MySQL/M-W.com windows that are mainly used for occasional reference. Being able to force a cleanup would be good. I'd still save the time to reload the entire page, even if it does take a second to redraw when I flip back to the tab.

      I'm not totally sure that I subscribe to your theory that Firefox is doing the right thing. If you start closing tabs/windows, you'll find that the memory is not cleaned up properly. I'd call that a leak.

      --
      If you don't want crime to pay, let the government run it.
    36. Re:Easier solution by mallie_mcg · · Score: 3, Interesting

      I understand your point, but how about something as simple as a "cleanup memory" button. I too often have several tabs open (4 instances right now with 24 tabs) but most of those tabs will sit idle most of the time, like my PHP/MySQL/M-W.com windows that are mainly used for occasional reference. Being able to force a cleanup would be good. I'd still save the time to reload the entire page, even if it does take a second to redraw when I flip back to the tab.

      Great for people like us, who knows whats going on in the background. Many people never run into the firefox memory issues because they tend to single process with their machines, and switch their machines off regularly. The solution should not be a manual thing, it should be able to be solved with clever programming (perhaps an idle, lack of mouse movement detection?) its hard enough to train users to use computers to do their jobs, without adding extra load to their fragile little minds. M

      --


      Do the following really mean anything? SCSA MCP CCSA CCNA
      --I'm not actually after an answer!
    37. Re:Easier solution by toddbu · · Score: 1
      The solution should not be a manual thing, it should be able to be solved with clever programming (perhaps an idle, lack of mouse movement detection?) its hard enough to train users to use computers to do their jobs, without adding extra load to their fragile little minds.

      Agreed. But the more complex you make it, the less likely it is to get done. I've seen threads on Bugzilla go on for years while people argue the nuances of an implementation. Better a manual process than no process at all.

      --
      If you don't want crime to pay, let the government run it.
    38. Re:Easier solution by GuyWithLag · · Score: 1

      The next major java release will have a memory allocator that will be able to give memory back to the OS. This is due to the fact that the C++ part uses a different (and smaller) memory pool than the java runtime. There is a reason why everyone is trying to move as much functionality as possible to the upper layers in VMs.

    39. Re:Easier solution by ultranova · · Score: 1

      Bah, it is just cache. If I have the memory available why not use it? Unfortunately Firefox isn't at a Kernel level and can't know if perhaps some portion of the memory would be better spent overall if it were used on caching the local I/O for example.

      Easy solution: Create a file in /tmp, memorymap it, and satisfy all requests for cache memory from the memorymapped region. Then it should compete on equal footing with all other filesystem IO, and be pushed out of disk cache and pulled back in as appropriate.

      Now lets see what obvious flaws I've overlooked in my master plan.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    40. Re:Easier solution by ultranova · · Score: 1

      And those new fangled Garbage Collection languages that haver their VMs witten in C++, and their heaps allocated using C++ allocators. Sure, they can relocate the objects inside those heaps, but once they get large... they tend to stay large.

      They don't have to, thought. A VM with a relocating garbage collector will have a few chunks of memory, with the active data located at the beginning of each chunk right after garbage collection. It is quite possible to resize these chunks with "mmap" and "mremap" system calls (based on their man pages, MAP_ANONYMOUS flag to mmap should do the trick).

      In C/C++, in-use memory segments are likely scattered all over the allocated memory space, making this kind of thing impossible.

      Remember, there is no problem that can't be solved by adding another layer of redirection: VM object reference -> virtual memory address -> physical memory address. Now imagine a Java virtual machine running a PC emulator running a Java virtual machine running a Beowulf cluster emulator running a distributed Java virtual machine running a multithreaded Hello World program ;).

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    41. Re:Easier solution by shadow0_0 · · Score: 1

      This is one attitude that I do not understand. Yes, this will solve the problem but when I buy a new computer or more memory, I want a FASTER and more powerful machine.

      If the memory usage is low, then I can run more applications with the same spec!

    42. Re:Easier solution by jonadab · · Score: 1

      > Leaked memory is memory which is still allocated to the leaking process

      Only if the operating system keeps track of which process it was that allocated the memory. In general, reasonable modern operating systems do this, of course, but there have been systems that didn't. Another thing that happened on those systems was that if one program had pointer errors, it could end up corrupting the memory of another process, and the OS wouldn't even know, much less prevent it. (That's also possible on systems that do know which process owns the memory but don't protect it from other processes, e.g. because there's no security model or because memory access doesn't have to go through the OS API and any process can execute whatever machine code it wants.)

      --
      Cut that out, or I will ship you to Norilsk in a box.
  2. Jerkiness by Froze · · Score: 2, Informative

    A quick read through the article (sacrilege, I know) claimed a small amount of jerkiness on uncompressing images. Does anyone have any idea how this would affect various hardware? For instance I have a 333MHz Pentium with ~144MB of mem that I expect (WAG) would get extremely "jerky" using this.

    --
    -- The morphemes of your disquisition are ascertainable, but they have eschewed an ambit of transpicuous exposition.
    1. Re:Jerkiness by Dammital · · Score: 1

      Federico's proof-of-concept code didn't try to do any lookahead staging. He suggested that Firefox decompress images adjacent to, as well as within the currently visible screen area.

    2. Re:Jerkiness by Anonymous Coward · · Score: 0

      Hmm, if you fire up kde and x.org in a 144mb ram machine, you will swap as hell after starting firefox. now when you open up some images that will need another tens of megabytes of memory to be painted, it is just insane. you end up swapping like hell forth and back while switching tabs, which is a lot slower than rendering the images even with that cpu.

      besides, try to think about handhelds and old machines too that are very very much memory limited, you can't possibly argue any of this there.

  3. X extension by obi · · Score: 3, Interesting

    He gives three possibilities: storing it uncompressed in the server, storing it uncompressed in the client, and storing it compressed in the client (and uncompressing it on the fly).

    I wonder if it might be interesting and worthwile to have an X extension to store it compressed on the server? That way there's a lot less X traffic, and potentially a lot more applications could make use of it.

    The only condition is that you don't need to decompress in Moz, and recompress it to send to the X server, but just pass along the compressed data (there's some security implications with that though, but I guess they could be dealt with).

    1. Re:X extension by obi · · Score: 2, Interesting

      One thing I forgot:

      if it's done on the server-side, it's probably also easier to take advantage of fancy graphics hardware. Imagine a graphics card that is able to decompress JPEGs on the fly, for instance (considering pixel shaders in current 3D hardware, it's not too far fetched).

    2. Re:X extension by emj · · Score: 3, Interesting

      The problem is that to store images compressed on the server you would have to decompress, resize, compress and then store it on the server, and you would still hav to keep the original in the client. Lots of the pictures on the web are resized before being shown by the browser.

    3. Re:X extension by obi · · Score: 1

      That's true, but the extension (and possibly the graphics hardware) could handle the resizing/viewport (and even rotating etc) operations for you too. Of course, I understand that it might be difficult to integrate such an API in Moz's codebase - I just don't know.

    4. Re:X extension by ianezz · · Score: 1
      I wonder if it might be interesting and worthwile to have an X extension to store it compressed on the server? That way there's a lot less X traffic

      I'd rather let Nomachine NX deal with the optimizations of X protocol transfers.

    5. Re:X extension by theCoder · · Score: 3, Interesting

      Well, along with that, why couldn't the X server compress the image itself, independent of the app? There wouldn't need to be any changes to the X protocol, this would be something done internal to the server. I suppose there could be an extension to the protocol that allows XPixmaps to be sent in JPEG compressed format or something as well, to reduce transmission time. If this was done, then apps like Firefox wouldn't have to change to get the benifit the author is describing.

      Besides, I'm not sure that storing the images compressed on the client side is going to work as well as the author hopes. In fact, it would increase the RSS of the firefox app, making people think that FF is even more bloated, even though it reduced memory usage overall. How many people have even heard of xrestop (I hadn't until I read the article)?

      --
      "Save the whales, feed the hungry, free the mallocs" -- author unknown
    6. Re:X extension by ltbarcly · · Score: 1

      BAH! The obvious thing to do is to remove the graphics from the X-Server after a timeout on tabs that are hidden.

      So the current tab has it's images on the X-Server, the hidden tabs have their images on the X-Server, but if you don't view them for 10 minutes they are free'd on the X-Server.

      This way there is equal performance for viewing pages, and a slight lag when switching to a tab you haven't viewed in a while. That lag is so small it might as well be nothing. There will be a noticeable lag when you are on a different machine then the firefox process. In this event you might like to have the option to cache all images in the X-Server.

      This is obvious.

  4. Other good side effect by GigsVT · · Score: 1

    Suppose you click a link to a huge (say 10 meg) image from a slow server or on dial up. Then you want to right click and save as. Since firefox might not keep a copy of the image in it's compressed form, you may very well wind up downloading that file from the server again.

    It may or may not get cached, I've definitely noticed situations where it does not get cached and must download completely again. There's a bug report on this behavior but I think it's closed as not a bug.

    --
    I've had enough abrasive sigs. Kittens are cute and fuzzy.
  5. It's the GDI objects by HughsOnFirst · · Score: 4, Interesting

    Windows has something called GDI objects (graphics device interface objects), and firefox uses too damn many of them.

    Somewhere after 5000 of them are in use windows slows down to a crawl and dies no matter how much memory you have, and with enough tabs and windows open firefox will be using 4000+ of them all by itself.

    1. Re:It's the GDI objects by Breakfast+Pants · · Score: 1

      Very true. On windows '95. Problems with system resources like this haven't been there since '98.

      --

      --

      WHO ATE MY BREAKFAST PANTS?
    2. Re:It's the GDI objects by HughsOnFirst · · Score: 1

      That's funny, I'm using windows 2000 and it very much an issue here. Not only that, it seems to be enough of an issue that some diagnostic programs like Iarsn Taskinfo by default pop up a warning when you use more than 4000 GDI objects. Where did you hear that problems with system resources had been fixed?

      Firefox using 256+ meg of memory I can deal with, but using 5000 GDI objects is ridiculous there are single pages that use 400+

    3. Re:It's the GDI objects by Anonymous Coward · · Score: 1, Insightful

      Very true. On windows '95. Problems with system resources like this haven't been there since '98.

      The GDI problems in Win9x were never fixed outright, just reduced. And the problems in Windows 2000 and XP are completely different, since they derive from NT.

      http://support.microsoft.com/default.aspx?kbid=126 962

      I've had older versions of ZoneAlarm hit this limit:
      http://support.microsoft.com/default.aspx?kbid=326 591

  6. Synchronicity... by benjamindees · · Score: 4, Interesting
    I'm right now running a copy of Opera on a system that's intentionally limited to 64 megs of RAM. It's working beautifully.

    I'm testing out browsers for use on some old machines as web kiosks. Basically, my choices are:

    • Konqueror - includes all of KDE (ugh)
    • Konqueror embedded - lacks maintenance
    • Firefox - seems to be slow and has issues when run without a window manager
    • Dillo - has website layout problems
    • and, Opera - seems to be the best choice


    These machines (P1), and lots of machines like them, pretty much max out at about 64 megs of RAM. I could probably find more RAM, but it'd be costly, and there are usually hardware compatibility problems.

    Although I'm leaning towards Opera at the moment, I was using Konqueror for a while. Linux does a great job of swapping, and Konqueror is quite snappy, so even with low memory it's a viable option. But, with all the libraries that Konqueror requires, 64 megs is kind of pushing it.

    And there is a decided trend in hardware towards less memory and faster processors. It's not uncommon to find Pentium III's with only 128 megs of RAM. Unfortunately, many open source programs are written without limited memory requirements in mind.

    It's kind of humbling to think that, as few as five years ago, a Pentium I with 64 megs of RAM would run an entire OS and web browser without so much as touching swap space. Today, you have to use apps designed for embedded machines to run in 64 megs of RAM, and you're lucky if you can run more than one app at a time.

    From my testing, Firefox is barely outside the range of viable options for a machine with 64 megs of RAM. But as with any performance tuning, there are probably trade-offs. And having lots of options is usually the best strategy. But I think these improvements suggested for Firefox would be beneficial in almost any scenario. Avoiding I/O seems to be the best strategy on any system newer than, say, a Pentium I, when web browsing. So uncompressing images on the fly in exchange for less memory usage would doubtlessly be a good trade-off.
    --
    "I assumed blithely that there were no elves out there in the darkness"
    1. Re:Synchronicity... by molnarcs · · Score: 1
      This is a me too reply :)) Both konqi and opera do fine on low-end hardware, konqi lags a bit behind opera in start-up time (because all the libs it loads) - but it is still much faster than firefox or other gecko based browsers (epiphany, galeon). And I don't think the problem is with images. Gecko is damn slow, that is the problem, and so is the interface under linux/bsd. Firefox works OK in win 98 (on pII 300Mhz machines with 64M ram) - until at least it eats up all the ram) while it is unusable on bsd/linux on the same box!

      We need other free software alternatives (my choice for these low end machines is opera for now). Maybe when konqi is ported to qt4? KHTML runs circles around gecko when it comes to rendering speed, and so does the speed of the interface and the memory consumption.

    2. Re:Synchronicity... by Anonymous Coward · · Score: 0

      64 megs of RAM is pretty unrealistic today. Why not simply replace these machines with Pentium 4 desktops with at least 512MB of RAM?

    3. Re:Synchronicity... by brunes69 · · Score: 3, Informative

      Konqueror - includes all of KDE (ugh)
      Konqueror embedded - lacks maintenance

      These are are both false statements.

      For one, you don't need "all of KDE" to build and run Konqeuror. All you need is the kdecore libraries, all of which put together have a much smaller footprint both in memory and diskspace than Firefox. If you don't beleive me, 'apt-get install konqueror' in Debian or any other distro that segments up KDE packages.

      For the second, Konqeuror embedded is built from the *exact same* cvs tree as Konqueror. Any commits to the rendering engine go to both browsers. So it does not 'lack maitenence', it is very actively developed, just like Konqueror.

    4. Re:Synchronicity... by MoogMan · · Score: 1

      Hey, you missed out Internet Explorer in your list of testing!

  7. Trade network traffic and CPU for memory by ianezz · · Score: 2, Interesting
    Since the X server can't deal (yet?) with compressed pixmaps by itself, and since we don't want to store the uncompressed pixmaps offscreen in the X server because it takes memory, the only way to do this is to have the application to uncompress the pixmaps on the fly and upload the needed bits to the X server each times it needs them.

    That's fine when the X server and the application are on the same host, but it is less than ideal when the X server is on a different host (you really want to send the data just once in this case). It's probably better to have it both ways.

    Possible outcomes:

    • applications could do that by themselves via specific support in the toolkit (i.e. let GTK+, Qt and FLTK deal with it)
    • the X server could transparently (read: internally, with neither the applications nor the toolkits knowing of it) compress pixmaps uploaded to it, uncompressing them when needed (really bad, because the X server would also have to compress them)
    • the X protocol could be extended to deal with compressed pixmaps (the X server would have just to uncompress them, but that's a new extension and the applications/toolkits need to be modified to use it)
    • leave everything as it is, assuming that X servers mainly run on systems providing virtual memory, which is quite cheap (bad for small/embedded devices)
    1. Re:Trade network traffic and CPU for memory by benjamindees · · Score: 1

      I thought of that too. But, in this instance, is it really important?

      Think of when a person would use a browser remotely over an X session. Isn't it more important to have a usable browser on the local machine than to have quick access to a browser via X11?

      And if they do run a remote browser, for something like LTSP, aren't they going to be using a local network, with relatively a fast connection anyways?

      So really you're talking about people who access a browser, remotely via X11, over a slow connection. Who does that?

      While I'd prefer a solution that can be tuned to specific usages, ie. fat client, thin client, and standalone, isn't tuning for standalone really the best overall option?

      --
      "I assumed blithely that there were no elves out there in the darkness"
  8. Out of memory by Elixon · · Score: 1

    :-) Decreasing the momory footprint is fine. But for the start I would be happy to don't see the message "out of memory" when downloading 30kB XUL code for my administration ;-)

    I prefer for the start bugfree Gecko that is consuming lot of memory. For me it is better to buy new memory then delay the development of my XUL CMS.

    --
    Well, I've got to get back to work. When I stop rowing, the slave ship just goes in circles.
  9. Interesting, but doesnt solve the biggest problem by meanfriend · · Score: 4, Interesting

    This was a nifty piece of investigation, but doesnt address the largest cause of firefox memory usage. Namely, memory is not freed when tabs are closed.

    See:

    https://bugzilla.mozilla.org/show_bug.cgi?id=13145 6

    Try a test. Fire up a clean FF and note memory usage. Go to somewhere like fark.com and open 50 links in tabs and note mem usage. Close every tab and see if mem usage goes down. It doesnt. Most people visit dozens of pages a day. Hundreds per week. After a while, the memory footprint of FF can grow to epic proportions (ie hundreds of megs) even with only a few tabs open because FF cannot release memory of closed tabs. I have to restart FF every week or so because I'm tired of it using 200MB for no good reason.

    It doesnt bother me so much that FF stores uncompressed images for tabs which are active (ie. open, even if not visible). The article itself mentions a performance hit when storing compressed images. But why the f*** cant it free the memory when I close that tab? The fact that I explicity closed it should indicate that I dont want it anymore. FF developers have acknowledged the problem but have said that there is no easy fix. Probably a poor design in the underlying architecture, though no one associated with the project would state it that bluntly.

    BTW, this article reminds me of one of the best reasons to use some sort of adblocking software. You save quite a bit of memory when you arent caching a dozen useless images with every new web page you visit. Especially in light of the above bug, you can significantly slow down the expanding memory footprint with adblocking.

  10. Which browser for older machines? by Skapare · · Score: 1

    One of the things I occaisionally do is set up older computers that would otherwise end up in an environmentally dangerous scrap heap so they can be used by people that otherwise be unable to afford a computer (at least one with all legal software loaded). A lean configuration of Slackware has worked well before. I'm considering using Ubuntu in the future, but it raises the lower limit on memory. And Firefox on any of these has posed problems.

    But the real problem is these older machines are limited in how much memory can be added at all. I have machines around that can't go above 32 MB or 64 MB. My own desktop is an 800 MHz machine that is now at the maximum 512 MB of RAM (the Intel chipset won't go higher) already has Firefox issues on a few web sites that are heavy on images and such.

    I do have the following suggestion I have made elsewhere which seems to be ignored by the Firefox developers. I can set Firefox to just not load images at all. But that is annoying. What would help a lot is to have a configuration setting to go ahead and load images, but just not run animations of animated images. In addition, a pair of buttons to turn on and off the image animations would be very valuable. Also, a right click menu item for each image individually that would allow turning it's animation on and off (present if that image is an animated one) would help. Same for Marquees.

    --
    now we need to go OSS in diesel cars
    1. Re:Which browser for older machines? by GigsVT · · Score: 1

      Get the developers toolbar extension.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
    2. Re:Which browser for older machines? by whitehatlurker · · Score: 1

      Try a filtering proxy - I know you're going toget hints for various extesions, but you should check out proxomitron.

      --
      .. paranoid crackpot leftover from the days of Amiga.
  11. Don't try to play Operating System by Clueless+Moron · · Score: 4, Insightful
    While it looks like a nifty idea at first glance, this kind of memory optimization is ultimately pointless when you have a nifty demand-paged vmem kernel like Linux.

    Consider: since my box has 1G of memory, I do want the X server to hang on the all those pixmaps, because that makes firefax run fast. The hack would make it waste CPU time re-uncompressing images, whether it's needed or not.

    With the way Firefox works now, if memory does start to run short, well, that's when the kernel will start paging things out based on its clever working set algorithms. If a given pixmap area in the X server hasn't been accessed in quite a while, it'll get swapped out to disk and the memory reclaimed. If the pixmap is accessed later, it'll automatically page back in.

    I don't know about your box, but mine (Athlon XP2000+) can decompress JPEGs at a rate of around only 3MB per second. My disk drives, OTOH, are a hell of a lot faster than that.

    In other words, letting the OS do its job by tossing the images onto swap when necessary strikes me as a much better strategy than constantly sucking up CPU decompressing every image every time it's used just in case the memory might be needed.

    People worry too much about VMEM, IMHO. If I write a program that allocates 1G of memory, but then spins around using only 10k for the next hour, it'll have basically zero impact on the OS. Only ~10k if real RAM is actually getting used.

    1. Re:Don't try to play Operating System by belg4mit · · Score: 1

      Firefox runs on things other than Linux, in particular
      isn't everyone supposed to be pushing for IE-FF switch?

      --
      Were that I say, pancakes?
    2. Re:Don't try to play Operating System by try_anything · · Score: 1

      Was this admonition aimed at FireFox developers or Microsoft Windows developers?

    3. Re:Don't try to play Operating System by joto · · Score: 2, Interesting
      People worry too much about VMEM, IMHO. If I write a program that allocates 1G of memory, but then spins around using only 10k for the next hour, it'll have basically zero impact on the OS. Only ~10k if real RAM is actually getting used.

      Not true. Say that after that hour, your program needs to access all of its memory again (because you deiconified it, or whatever...). And that you have done other stuff during the last hour, that caused the rest of your gargantuan memory hog program to be paged out to disk. That means 1GB needs to be loaded from disk.

      At about 18 MB per second (which is what I measured when trying "time cat somemovie.avi > /dev/null"), that would take about a minute.

      Paging to disk is no longer a solution to the problem of running out of memory. With most users having >512MB RAM, it just takes too long to reload memory from disk. Swapspace is obsolete! Besides, linux paging and disk scheduling isn't that smart. Try to do something productive at the same time as updatedb is running.

      In the future, we may be able to swap to some cheaper slower memory, a solid state diskdrive, or something else. But untill then, both memory usage and disk time is a scarce resource. On the other hand, multicore has already arrived. CPU is going to get cheap!

      I don't know about your box, but mine (Athlon XP2000+) can decompress JPEGs at a rate of around only 3MB per second. My disk drives, OTOH, are a hell of a lot faster than that.

      I agree you have a point here. I'm not advocating decompressing jpegs on the fly when scrolling. Memory is scarce, but not *that* scarce. But saving memory by discarding uncompressed images from closed windows and tabs, and "back" pages, would be a good start. You only need speed for common operations. Wasting tons of memory on things rarely done, will eventually slow the whole system down.

    4. Re:Don't try to play Operating System by at_18 · · Score: 1

      I don't know about your box, but mine (Athlon XP2000+) can decompress JPEGs at a rate of around only 3MB per second. My disk drives, OTOH, are a hell of a lot faster than that.

      No they aren't. Unless you are only reading very large files (from several megabytes up), seek time will kill your transfer rate. And paging memory seems to require lots of seeks.

    5. Re:Don't try to play Operating System by icepick72 · · Score: 1
      because that makes firefax run fast

      Awesome. I want one.

    6. Re:Don't try to play Operating System by ultranova · · Score: 1

      People worry too much about VMEM, IMHO. If I write a program that allocates 1G of memory, but then spins around using only 10k for the next hour, it'll have basically zero impact on the OS. Only ~10k if real RAM is actually getting used.

      Actually, it will use 12k on a system with 4k pagesize (such as x86).

      On a more serious note, if you are going to rely on swap to take care of caching, you don't want to store the data in X-servers address space. On a 32-bit machine, that space is 4 GB at absolute theoretical maximum, so you are going to run out if you have several programs using this method running simultaneously, unless the X-server itself has some cache-to-disk algorithm - but of course any such algorithm will invariably add overhead.

      Keep most of the bitmaps on Firefoxs memory space and send them as neccessary. It shouldn't be particularly costly in the most common situation of Firefox and X-server running in the same machine.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    7. Re:Don't try to play Operating System by Anonymous Coward · · Score: 0

      I don't know about your box, but mine (Athlon XP2000+) can decompress JPEGs at a rate of around only 3MB per second. My disk drives, OTOH, are a hell of a lot faster than that.

      This isn't the whole picture.

      If your CPU can decompress JPEGs at a rate of *input* of around 3MB per second; that's 30MB per second of output. If your disk drives are "a hell of a lot faster than" 30 MB per second, your computer is not by any means a typical system, and therefore no use to us in optimizing Firefox.

      Not to mention that, once you're so low on memory that you have to start swapping, the whole system's speed is now significantly slower. By storing things compressed, it takes less memory, so you remove much of the need to swap in the first place, thus speeding up even completely independent apps. For example, if you have 10 Firefox windows open, they might have 300 MB of (uncompressed) data; by storing it in compressed form, you might only need 50 MB, and thus save 250 MB, or 1/4 of your memory.

      I have 1 GB of RAM, also, and yet I'm always using swap -- mostly due to Gecko. My CPU is only 900 MHz, but I'd gladly do a decompress-when-needed to save memory. When you're browsing a webpage, swapping is merely an inconvenience, but if you're playing music, recording music, watching a movie, etc., swapping ruins the experience.

  12. Re:Interesting, but doesnt solve the biggest probl by Skapare · · Score: 3, Insightful

    I've switched to opening links in new windows a lot now. In part this is because I want to group a set of tabs together. And it's easier to just close the whole mess by closing that whole window (generally all on one site or about one topic). But it seems FF is not free-ing up memory in these cases, either.

    I don't see why a tab or a new window should be different internally, though. It should only be a matter of associating the state of a loaded page with a given display context. The real issue, though, is the memory management issue. Apparently something fundamentally wrong in the browser architecture is preventing that. I highly suspect it is due to over-abstraction and/or the inability of some tools they are using to properly destruct objects that are no longer needed. It does seem that large complex software projects such as this do tend to suffer a lot of complexity issues that result in basic things like free-ing memory becoming impossible to do. I don't encounter these problems in my programs, but then, I don't do anything nearly as large as Firefox, nor do I use a team of developers, nor do I use all these abstract tools by ignoring their internal operation implementations. I'll be curious as to the actual, real cause.

    --
    now we need to go OSS in diesel cars
  13. A bit basic by alanjstr · · Score: 1

    It is an interesting notion, but I see problems with the methodology.

    The biggest problem is that there is a big hit to user experience. Changing tabs and scrolling faster than your wheel will suck.

  14. So I guess running it on a 16MB machine is out? by Anonymous Coward · · Score: 0

    I've got a couple of 16MB & 24MB Compaq laptops that are running the Damn Small Linux distro.
    I think the Firefox version shipped with DSL is 0.93
    I guess I won't be upgrading to 1.5 anytime soon :-(

  15. recompress by TheSHAD0W · · Score: 2, Insightful

    This is a pretty neat idea, but JPEG compression tends to be rather CPU-intensive for various reasons. I'd recommend either recompressing to a more reasonable format - LZW, for instance - or perhaps going to an intermediate compression also based on JPEG but requiring less CPU to deal with. For instance, decompressing to 32- or 64-bit fixed-length tuplets rather than the LZ or numerical compression used in the files.

    1. Re:recompress by LnxAddct · · Score: 1

      No compression is necessary, only decompression, which is fast. The image comes compressed, no computation on your part, you decompress it when it needs to be viewed, keep the compressed version in memory and simply delete the uncompressed version when no longer needed.
      Regards,
      Steve

  16. Extensions by hug_the_penguin · · Score: 2, Interesting
    Fine, compress images, but extensions, to those who use them are a much bigger problem. I switched to epiphany because I had a tendency to overload firefox with extensions (and besides ephy is faster even with a clean firefox).

    When you have as few as 5 extensions, memory and CPU usage soar terribly. I realise this won't affect 80% of users like images would, but certainly 95% of FF-using slashdotters it will affect.

    Surprisingly flock doesn't appear to suffer as badly from either problem, perhaps they've put it on a diet?

    --
    ~HTP~ Hug that tux ;)
  17. Re:Interesting, but doesnt solve the biggest probl by dtfinch · · Score: 1

    Firefox simply never releases memory, AFAIK. But it'll reuse the memory.

  18. Scattered memory allocations by Skapare · · Score: 4, Interesting

    One possible contributor to the memory issue here, and in some other programs, could be the way the memory is allocated. Memory is obtained from the kernel in chunks a multiple of a page size. These pages cannot be returned back to the kernel unless all usage of the entire page is gone. Memory usage for a typical object tends to be small pieces. If the pieces allocated for one page (in one tab) are interleaved with pieces allocated for another page (in another tab), then closing one of those tabs, even if the mainline code destructs all objects which correctly free all their underlying memory allocations, does not necessarily result in pages being released back to the kernel.

    So how can memory allocations get scattered around like that? Consider that many objects need to persist as long as the page exists, but many others can be destructed because they are only needed when the page is being loaded or rendered. During loading and rendering, both sets of objects can be created in a mixture. Then the non-persistent ones would be destructed. Because of the order of allocation of underlying memory, the persistent objects tend to be interleaved with the non-persistent ones. That then means most pages may have some persistent object lying around, preventing it from being returned to the kernel.

    Solutions to this problem would be difficult. But I also think this effort would be valuable for any and all large projects that can face this kind of memory issue. Some means is needed to control the memory alloction, and in particular to allow grouping of memory into contexts. The first kind of context would be a context for each tab or window being opened by the browser user. That way, if a tab is closed, it should substantially destruct objects grouped together. But this can also be wasteful because the non-persistent objects that do get destructed after rendering is done cannot have their memory recycled by other contexts. So another dimenstion of context needs to be on the basis of what is persistent vs. non-persistent, so that all non-persistent memory gets grouped together so it can be returned to the kernel as whole pages, which can then be recycled to other contexts (getting the pages from the kernel again).

    This would require a much more involved memory allocation system. Further, it would also require major changes in many of the abstract programming classes used by such large programs ... in ways that tend to be counter to what the abstraction is all about in the first place. Abstraction is supposed to hide details about the underlying implementation so the programmer can/should concentrate on application logic. But this is not really an optimal way to program when dealing with limited resource issues that need to be managed, such as the memory issues seen here. In particular, the various classes themselves won't know whether they are persistent (in the context of what the browser application needs) or not. Many instances of the very same class may be created for both persistent and non-persistent intents, so the class itself could never be designed to make any such assumptions (e.g. think of hiding the details in reverse ... the class does not see the details of the application, e.g. which instances are to be long lived and which are not).

    A concept that may help with this is one that would have to be applied to the whole of such object oriented programming, or even non-OO functions that also could allocate memory for such variant uses (this isn't fundamentally an OO problem ... OO merely exposes it due to the larger application scale that OO enables to be implemented). This concept is to create instance groups that can span laterally across all classes. It would require that each time an instance is created, that it be associated with a particular instance group. Then instead of destructing each instance individually, the group is destructed, which destructs all instances in the group. The implementation of all thi

    --
    now we need to go OSS in diesel cars
    1. Re:Scattered memory allocations by kristjansson · · Score: 1

      So, you're basically talking about a NeXT/OSX-ish implementation of memory zones and the Objective C retain-release mechanism...



    2. Re:Scattered memory allocations by convolvatron · · Score: 1

      the solution to allocation inefficiencies due to fragmentation is well known.
      it doesn't require any substantial changes to the programming model. use
      a coalescing garbage collector. since you are moving objects it requires
      either use of mprotect() to trap stale references or lock the object against
      mutation during the copy, or the assumption that one can 'stop the world'
      while copying objects.

      as usual the overhead of copying can be tuned by policy, and mitigated through
      the use of a standard generational implementation.

      having just exposed a memory leak in ff 1.5 using svg w/ javascript, i really
      do wish they would have chosen to just gc the whole thing

    3. Re:Scattered memory allocations by woolio · · Score: 1

      Wouldn't it be simpler just to have Firefox manage its own memory ? I think it might be possible without a complete overhaul. (But I'm far from being a firefox developer)

      If the problem is that new windows tabs create a lot of objects that each get interspersed in memory, then why don't they just:

      Overload "new" so that objects from each page are allocated from separate pools of memory. (using separate 4k memory pages for each tab/window wouldn't be a big deal)

      Many times, applications do something similar so that they can create and delete many objects rapidly without the incurring the overhead of (implicitly) calling malloc and free each time....

  19. Its all about cost by brunes69 · · Score: 1

    Time is expensive. Ram is cheap. do the math.

    Say you have 500 customers, if they each have to get 512 MB of extram ram to run your software, the cost of that would run about 512 * $50 = $25,000, give or take.

    Now, say instead, you get your development team to spend 3-4 weeks chasing down memory issues and optimizing the code to be lean and mean. Even if the team is very small (10 people), that just cost you $40,000 to $50,000 in salaries, not to mention the lost time they could be working on something else.

    See the point? You could *buy the ram for the customers yourself* and it woudl still be cheaper than paying your developers to chase after leaks.

    1. Re:Its all about cost by An+Onerous+Coward · · Score: 2, Insightful

      In this case, though, the number of customers is on the order of a hundred million people.

      Care to do the math again? :)

      It's an important point, though. Sometimes programmer time isn't used terribly efficiently.

      --

      You want the truthiness? You can't handle the truthiness!

    2. Re:Its all about cost by Captain+Splendid · · Score: 1
      So....what you're saying is the Firefox team needs to give out a free stick of RAM with every download?

      I keed, I keed. (running 1.0 something on win2k athlon xp 1800 w 1 Gig RAM. It never crashes or hangs.)

      --
      Linux, you magnificent bastard, I read the fucking manual!
    3. Re:Its all about cost by Kris_J · · Score: 2, Interesting

      At work we have half a dozen PCs (of ~22) with the maximum amount of RAM installed that they support. The list includes my laptop. I am therefore for anything that reduces RAM use and against any lazy programming that requires more RAM.

    4. Re:Its all about cost by Anonymous Coward · · Score: 0

      "I am therefore for anything that reduces RAM use and against any lazy programming that requires more RAM"

      On behalf of lazy programmers: We're sick of you too.

      ;)

  20. usefulness by zogger · · Score: 1

    with knoppix and some other live cds you can use a cheatcode (I think it's knoppix:toram or some such) and when it is booting it puts the entire OS into RAM if you have enough, like you have. I do this with a mini distro, austrumi, and it makes it *blazingly fast*, as in quick. Like a megaprocessor upgrade or something. Knoppix is I think 2 gigs compressed with the single CD version, so 4 gigs of ram would give you some decent cushion.

  21. Re:Interesting, but doesnt solve the biggest probl by GigsVT · · Score: 1

    The memory in question is not taken by firefox process per se, it's memory resources in X11 or Windows that are never freed.

    --
    I've had enough abrasive sigs. Kittens are cute and fuzzy.
  22. Never send a boy in to do a man's job by xenocide2 · · Score: 1

    Or something perhaps a bit less sexist; that's all I could come with on short notice. Point is, the operating system is fine and dandy for general purpose computing, and has lots of tweaks, but at the end of the day the general purpose OS must to generalize it's algorithms for ALL programs by definition, wheras the application itself knows best which parts of its working set are nessecary and which are trivial.

    Exokernels take this concept to the extreme and let applications decide where to allocate their resources and whatnot, while the OS simply "securely multiplexes hardware." I have yet to discover how this can possibly work safely, but my gut intuition is that even if this does work, most application developers aren't prepared to take on the burden traditionally handled by the OS.

    But even without having super duper access to resource allocation primitives, you can still make some sensible choices. For example, a tradeoff between CPU cycles and memory utilization like compressing large images. If your computer consistantly triggers underclocking because it's not used much, it might make sense to compress images and free up more space for other applications or more file cache.

    --
    I Browse at +4 Flamebait

    Open Source Sysadmin

  23. This is not either/or, people by Kris_J · · Score: 3, Interesting

    This is exactly the sort of thing you handle with a slider in the options; "How would you like Firefox to handle images" with High CPU/low RAM on one end and Low CPU/High RAM on the other. The slider would determine how aggressively Firefox caches uncompressed images.

    1. Re:This is not either/or, people by Anonymous Coward · · Score: 0

      This is exactly the sort of thing you handle with a slider in the options; "How would you like Firefox to handle images" with High CPU/low RAM on one end and Low CPU/High RAM on the other.

      Are you high? This is exactly the sort of low-level crap I don't give a shit about. If it had a slider for this, we'd have to call it "Mozilla", so people would know to shun it.

      The whole point of Firefox is to get rid of crap like this that people don't care about.

  24. Re:Interesting, but doesnt solve the biggest probl by Anonymous Coward · · Score: 0

    Try a test. Fire up a clean FF and note memory usage. Go to somewhere like fark.com and open 50 links in tabs and note mem usage. Close every tab and see if mem usage goes down. It doesnt.

    Be sure to minimize every Firefox window in between, at least on Windows. (and turn on the "VM Size" tab) Tracking usage in Task Manager is a bad way to isolate leaks like this. In fact, I don't know of a good way on Windows, I've never worked on something as large as FF.

  25. Re:Interesting, but doesnt solve the biggest probl by Anonymous Coward · · Score: 1, Informative

    Sigh. You have a very poor understanding of memory usage patterns.

    Applications will seldom free memory back to the system, even though it has been freed within the program's memory manager (malloc etc). Most Unix systems give applications a single contiguous chunk of virtual memory that typically only grows rather than shrinks (due to memory fragmentation). That is a terriblly ineffective way to diagnose a memory leak.

      AC

  26. Who modded this crap up? by SigNick · · Score: 1

    A 512MB DDR2 stick can be easily bought for 30-40 and a 512MB PC3200 (=DDR1) stick for 39-49.

    I recently upgraded my laptop with a 1GB DDR2 SODIMM module, total cost: 99.

    $200? Nice joke buddy but no cigar!
    Also, maybe pure MHz hasn't gone up more than 15-20% but pure 'speed', or performance/ has at least tripled. I got my AMD X2 4200+ cheaper than a P4/2533 only a few years ago and the difference in practice in LAME/Xvid/games is on a completely different scale.

    --
    Capitalization is the difference between "Helping your uncle jack off a horse" and "Helping your uncle Jack off a horse"
    1. Re:Who modded this crap up? by GigsVT · · Score: 1

      Look, I just went on the first thing I saw on crucial. I didn't notice it was very high end at the time.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
  27. CPU Usage by FF3451 · · Score: 1

    I have of course noticed that Firefox uses quite a lot of memory, but it is the CPU usage that is of a greater concern to me and actually causes me problems.

    I have an Athlon 64 3000+ and a gig of RAM, and I regularly go to use an application that has a genuine need for a lot of CPU e.g. a game, to find it runs slowly and then upon investigation Firefox is found to be using 50% or more of my CPU!

    I have investigated further and the problem seems to relate to tabs containing Flash, I have had to get into the habit of making sure I don't keep pages open that contain flash banner ads etc (which I already found to be an annoyance, and unfortunately are appearing on an ever-increasing number of sites). Has anybody else had a similar experience? Is it Flash using all the CPU, or an inefficient interfacing with Flash by Firefox? Having a few pages containing Flash open shows immeasurably small CPU usage, but add a few more and it skyrockets :(

    1. Re:CPU Usage by Anonymous Coward · · Score: 0

      Flash itself is slow and the renderer is even slower. If you have an ad with say 5 half transparent layers it can easily eat 95% of the cpu cycles. With an older machine it sometimes feels like DoS (eg it takes a minute till you actions shows effect).

      For this very reason I installed adblock and set it up to filter swf files. You enable/disable it with ctrl+shift+b.

      IMO its silly to waste that much cycles (and thus energy/money [if the cpu is used it doesnt HLT]) for flash ads.

    2. Re:CPU Usage by FF3451 · · Score: 1

      Yes, I had thought about the fact I'm not actually making use of the power-saving technology of my CPU due to this problem! Luckily the PC is fairly quick so I don't get a DoS-style slowdown, just a noticeable and annoying one.

      I had been looking at various extensions myself to block the loading of SWF files, thanks for that piece of info, sounds like adblock is ideal if it can provide me with a hotkey to turn it back on when I am e.g. viewing a flash animation or game. Flash advertisements on the other hand are just an abomonation that I wish had never graced our screens.

    3. Re:CPU Usage by deaddrunk · · Score: 1

      flashblock is brilliant, it puts a play button on each piece of flash and only runs them if you click it so perfect for avoiding so many annoying ads while still being able to use sites that require it.

      --
      Does a Christian soccer team even need a goalkeeper?
    4. Re:CPU Usage by FF3451 · · Score: 1

      Brilliant... Once again that's a very useful piece of information, many thanks for that :)

  28. Re:Interesting, but doesnt solve the biggest probl by sleepingsquirrel · · Score: 1
    I wonder if it is related to the resource leak associated with "Bugzilla Bug 246974: CPU usage reaches 99% and will not go down"...
    https://bugzilla.mozilla.org/show_bug.cgi?id=24697 4