13

I am primarily using Firefox as my web browser. I have noticed that after some tabs having been opened and closed the memory usage of Firefox becomes larger and larger.

This fact often leads me to crash it (deliberately using the task manager) and to open it again selecting only some of the tabs I need. There are cases where I open all my previously open tabs. The funny thing is that even in this case, the memory usage is by far less than what it was before shutting Firefox down.

So my question is why is this happening? Why does the closing of the tabs not help (at least not that much)? Is there a way to reduce the memory usage without shutting Firefox down?

migrated from webapps.stackexchange.com Jul 29 '14 at 9:27

This question came from our site for power users of web applications.

  • 1
    When you say "memory", what precisely do you mean? Resident set size? Commit charge? Virtual address size? How are you measuring and what operating system are you using? Also, why do you deliberately crash it? Are you having some kind of actual issue? Or do you prefer that RAM be wasted than used? – David Schwartz Jul 29 '14 at 9:32
  • 1
    Sorry, about the missing information. I am using win7, I am referring to RAM memory, I am measuring simply observing the task manager tab so the memory estimation may not be too accurate. The fact is that firefox sometimes uses upto 2Gb of memory which does not seem reasonable for the number and content of tabs being open. – Eypros Jul 29 '14 at 9:45
  • Which tab --"Working Set (Memory)"? – David Schwartz Jul 29 '14 at 10:04
  • 1
    I can recommend small addon that allow restart firefox in easy way. addons.mozilla.org/ru/firefox/addon/restartless-restart – Mikhail Moskalev Dec 21 '14 at 12:00
  • 1
    Possible duplicate of Is there a way to reduce the memory usage of Firefox? – YetAnotherRandomUser Feb 28 '18 at 20:38
5

Enter about:memory in the address bar. Click 'Minimize memory usage'.

https://support.mozilla.org/en-US/kb/firefox-uses-too-much-memory-ram

  • +1. I don't know if it will solve all my problem but it was useful anyway, so thanks. – Eypros Jul 29 '14 at 9:49
  • 7
    This completely fails to answer the primary question asked. "Why does my Firefox memory usage keep rising with use and never returns to the initial level?" – David Schwartz Jul 29 '14 at 10:48
  • And, by the way, you would only want to do this if you were testing or benchmarking. It just forces your system to waste memory that it was using, even if it doesn't need to. (It does it automatically if it needs to, the people who write Firefox aren't stupid and wouldn't make you senselessly hit a well-hidden switch just to get things to work better.) – David Schwartz Jul 29 '14 at 10:48
4

The first thing I would suspect is that some of plug-ins leak memory or use it a lot.

For example, AdBlock Plus often causes Firefox to increase memory usage significantly. The reason is that it injects large style sheets into every frame. (Ghostery is a more memory-efficient alternative, although it serves a different purpose.)

So, as suggested in the comments, if memory usage doesn't seem reasonable, try disabling all plug-ins and see if this helps.

1

If you need the RAM for other purposes, just restart Firefox. It will minimize it's memory usage, too.

You can even say to Firefox that it does not have to load all pages upon restart:

Firefox button -> Options -> Tabs -> Don't load tabs until selected

Also, I have noticed a high memory usage from Adblock Plus. Adblock Edge does not seem to have this issue. Disabling Adblock Plus also frees memory.

0

RAM cannot be saved for later. Your only choices are to use it or waste it. A system with 8GB of RAM can't use 4GB today in order to use 12GB tomorrow.

So, simply put, Firefox is using more memory because the alternative would be to waste that memory. It is not returning to the initial level because it would take effort to do so and there would be no benefit to expending that effort.

The fact is that firefox sometimes uses upto 2Gb of memory which does not seem reasonable for the number and content of tabs being open.

It's perfectly reasonable if the alternative is to have some of that RAM be wasted and holding no data whatsoever. At a minimum, it allows Firefox to use up to 2GB of memory without having to allocate any more memory, which is a win. Freeing and allocating memory takes effort. Smart systems only expend effort when there's some expected benefit. They certainly don't do work that they'll probably just have to undo later.

Modern operating systems go out of their way to have as little free RAM as possible. Free RAM is forever wasted. If you had 1GB free for the last hour, you gained no benefit whatsoever from that 1GB in that past hour. If you're thinking, "I want that RAM free now so I can use it later", forget it. You can use it now and use it later. There's no painful tradeoff to make here.

  • 6
    Maybe we are entering a philosophical conversation about what is useful. From my point of view I cannot use the memory holding "possibly useful information" as you mentioned since it's allocated by firefox. So I could just get an out of memory message from other application I am using. – Eypros Jul 29 '14 at 9:58
  • 4
    @DavidSchwartz: this is complete nonsense. what the hell is "directly transition the memory"? if memory is scarce, one application has to give so another can take (the alternative is the dreaded swapping..). "Modern operating systems do this very efficiently" - do what?? they can get rid of code and library pages because they can be re-fected, they can play with the FS cache pages, but cannot take away memory that's normally used (e.g.: firefox storing a closed tab or images so they can be opened faster). – Karoly Horvath Jan 20 '15 at 11:09
  • 11
    -1 for exactly the same reason as @KarolyHorvath. On a 4 GB machine (which is only "less-that-average" nowadays), FF taking 2.5 GB of resident memory (I'm on Linux) is unreasonable, because it takes memory away from other applications. When I close several tabs, I expect FF to release the now unused memory, so that other applications, or the kernel itself for that matter (which likes to cache aggressively, greatly increasing overall performance) can use it. This is the archetypal developer/sysadmin dispute, if you don't need the memory anymore, release it, you're not alone on that system. – MoonSweep Apr 19 '15 at 22:02
  • 7
    Downvote for one of the stupidest ideas around: "Let's waste memory for fear it will go unused" – lemonsqueeze May 11 '15 at 20:26
  • 6
    You seem to be arguing that it's okay for Firefox to bloat up to 2Gb because that memory is just swap and so other programs are not prevented from having that 2Gb. This is false. Most of that 2Gb is dirty pages which have to be flushed. Out. Moreover, when Firefox decides to run some garbage collection on that cruft, it has to be paged back in: and that will happen in some random order that causes seeks all over the place on a conventional spinning hard drive. Not writing 2Gb to disk and reading it back is demonstrably more performant than doing so. – Kaz Aug 12 '15 at 19:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.