Would love a setting to limit Firefox memory use

Discussion of features in Mozilla Firefox
Post Reply
srs06
Posts: 11
Joined: October 18th, 2008, 7:28 pm

Would love a setting to limit Firefox memory use

Post by srs06 »

Mostly running on Windows (some Linux, some FreeBSD but problem is mostly on Windows). Current release -- Firefox 67.

What would seem to be ideal is some setting that caps the amount of RAM Firefox can claim. I know all the ways to reduce high memory use when it occurs, but in the middle of a workday, what I often experience are situations where I end up going back and forth between web searches and work. That often leads to a lot of open tabs that I want to bookmark later. Firefox does its thing and uses almost all available RAM and all is fine if I'm just using Firefox. The problem comes when I need to open something new or start using an app that was minimized and using low memory. Rather than be forced to take the time to free Firefox memory, why not just allow some reserve to be kept available for other applications? Maybe not easy but I thought I'd throw it out there ...
kerft
Posts: 585
Joined: January 30th, 2019, 9:38 am

Re: Would love a setting to limit Firefox memory use

Post by kerft »

The 32-bit version of Firefox will run on 64-bit Windows. As a 32-bit application, each process of it will only use 2-3gb of ram. Set, in about:config, browser.tabs.remote.autostart to false. That will disable all multiprocess functions so Firefox will use only one process with 2-3gb of ram. Note, as of Firefox 67 using this flag to disable multiprocess is officially unsupported. Firefox may out of memory crash with these settings.

Alternative that gives a nice security benefit also: make a virtual machine, run Firefox in it. Virtual machines usually have a fixed max memory amount you give them.

Third option: use the session saving feature of Firefox - when multitasking becomes needed, close Firefox and when you need it again session restore will bring back what was there.
User avatar
RobertJ
Moderator
Posts: 10880
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Re: Would love a setting to limit Firefox memory use

Post by RobertJ »

.
Not a support issue. Moving.

.
FF 92.0 - TB 78.13 - Mac OSX 10.13.6
User avatar
therube
Posts: 21703
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Would love a setting to limit Firefox memory use

Post by therube »

"The 32-bit version of Firefox..."

Now all that is a really interesting thought, one that I never even considered until reading your post, thanks.

Before now, my thought process was like, well "FF" be it a single process or multi, is using XYZ GB of RAM, & in my mind I considered it a "single" process, even when running multiprocess. Likewise, my immediate thought on reading your post was, 32-bit, "FF" is only going to use, at most 4 GB of RAM, never even considering that each FF "process" had its own address space, so potentially each could use 4 GB.

So, purposely downloaded the x86 version, just to see what would happen, & sure enough I'm using > 4 GB of RAM for FF (in multiprocess configuration).
And with that, neat.
But, & you know there's always a but, for whatever reason, & "only" using ~6 GB of RAM, yep, crashed.
xul.dll, with a hint towards OOM.
Not the "last thing I expected", just didn't expect it at the particular time it happened, as things had been running well - up to that point.


(As the song says, that's playing currently, "I can't explain what happened", https://www.azlyrics.com/lyrics/bradpai ... anced.html.)
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
User avatar
therube
Posts: 21703
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Would love a setting to limit Firefox memory use

Post by therube »

How much physical RAM do you have?
I've got 16 GB.
Not unusual for my browser to be eating much RAM - all the while I'm multitasking any number of other programs.
Only odd situation that comes to mind is that my (external) media player will every once in a while, fail, not so much because of "RAM" usage, but more (I'm thinking) some "resource" (like GDI resources from the old days) that the browsers are eating, that my media player is also expecting, but not finding enough, so failing. At that point, I'll close a browser instance, & my player is good after that.

So IMO, if you have sufficient RAM & a relatively able system (i5-3570k here, so kind of dated at this point), I wouldn't particularly expect to be seeing issues.
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
srs06
Posts: 11
Joined: October 18th, 2008, 7:28 pm

Re: Would love a setting to limit Firefox memory use

Post by srs06 »

therube wrote:How much physical RAM do you have?
I've got 16 GB.
Not unusual for my browser to be eating much RAM - all the while I'm multitasking any number of other programs.
Only odd situation that comes to mind is that my (external) media player will every once in a while, fail, not so much because of "RAM" usage, but more (I'm thinking) some "resource" (like GDI resources from the old days) that the browsers are eating, that my media player is also expecting, but not finding enough, so failing. At that point, I'll close a browser instance, & my player is good after that.

So IMO, if you have sufficient RAM & a relatively able system (i5-3570k here, so kind of dated at this point), I wouldn't particularly expect to be seeing issues.
The Windows system (Windows 7) has 24 GB of RAM. There are almost always about two other higher memory use apps running, one being Thunderbird. The issue, as I tried to state, is that when Firefox uses most of the available RAM I have problems doing other work. The pattern of use on that machine is to use the browser to find information related to other work I'm doing. It's often too time consuming (deadlines, etc.) to bookmark everything as I find it. And I may end up needing quite a few tabs of information. So I find that info, Firefox uses a lot of memory as a result (lots of new open tabs), then I try to flip over to use the information I found and the system is barely usable. I'd be willing to trade off Firefox performance for the ability to be able to do the other work ... it seems if you could give Firefox a limit so there's some RAM in reserve for other apps that might work. SQL Server has a setting like this -- how much memory it's allowed to take in total.

I've played around with dom.ipc.ProcessCount settings and that often changes things a bit but I always end up at the same basic spot, which is Firefox using most of my RAM and I need to do something else and can't. The other thing that often happens here is some of the open tabs just show blank/spinning for long periods of time and closing a few obvious tabs I don't need doesn't seem to really do anything. From what I've observed, it seems like closing tabs individually will eventually free up RAM without restarting Firefox but it can sometimes take a while for it to have an effect (it seems to take some period of time for Firefox to give back RAM it doesn't need any more).
srs06
Posts: 11
Joined: October 18th, 2008, 7:28 pm

Re: Would love a setting to limit Firefox memory use

Post by srs06 »

kerft wrote:The 32-bit version of Firefox will run on 64-bit Windows. As a 32-bit application, each process of it will only use 2-3gb of ram. Set, in about:config, browser.tabs.remote.autostart to false. That will disable all multiprocess functions so Firefox will use only one process with 2-3gb of ram. Note, as of Firefox 67 using this flag to disable multiprocess is officially unsupported. Firefox may out of memory crash with these settings.

Alternative that gives a nice security benefit also: make a virtual machine, run Firefox in it. Virtual machines usually have a fixed max memory amount you give them.

Third option: use the session saving feature of Firefox - when multitasking becomes needed, close Firefox and when you need it again session restore will bring back what was there.
I don't really want to limit Firefox to 32-bit levels of RAM. I also need multi-process. And I already have VM's in use ... not really interested in complicating things there.

There are hardware upgrades I know will address the problem. But without Firefox running or with Firefox running with a reasonable number of tabs open, everything still performs extremely well on that machine. Financially, the ideal upgrades I want to make are still a bit in the future. Hence, I'm looking for some way to better manage Firefox memory use in the interim.
User avatar
therube
Posts: 21703
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Would love a setting to limit Firefox memory use

Post by therube »

What CPU?
What are RAM/CPU usage numbers for your various programs when you run into this situation?

This is what I alluded to above, Not Enough Storage Space Is Available To Process The Command.
Pretty sure that only occurs pre-Quantum (as in I don't recall running it that situation with Quantum).
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
srs06
Posts: 11
Joined: October 18th, 2008, 7:28 pm

Re: Would love a setting to limit Firefox memory use

Post by srs06 »

therube wrote:What CPU?
What are RAM/CPU usage numbers for your various programs when you run into this situation?

This is what I alluded to above, Not Enough Storage Space Is Available To Process The Command.
Pretty sure that only occurs pre-Quantum (as in I don't recall running it that situation with Quantum).
I don't get any error messages. Once in a while Firefox or Thunderbird will crash but that's rare. Mostly things just get extremely slow or totally unusable. If I wait long enough that will eventually clear, at least a bit.

One thing I notice is when the highest memory use Firefox process goes over 1GB, that's when it starts getting a lot worse. I looked at a recent case and I had over 45 tabs open (including several pinned tabs). So I tried increasing dom.ipc.ProcessCount to 50 to see what would happen. I ended up going a lot longer and for a long time no Firefox process hit the 1GB mark. Eventually though (today, after about 24 hours) the biggest Firefox process was up around 3GB and total RAM use was under my total of 24GB but over 22GB. Same thing even after closing tabs and closing the bookmarks window (which seems to sometimes make a decent difference). It's usable at that 22GB plus level but it can go almost to a stop if I try starting a new app. Right now there are around 40 tabs or a little less open, whereas right after I made that dom.ipc.ProcessCount increase it ran for many hours at about half the RAM use (right around 11GB total for a long time). I understand some of this is probably what's in a specific tab ... it would be great if memory use per tab could somehow be examined. But there are also only about 5 new tabs open over what I had yesterday -- but after closing about 10 I didn't need and won't be bookmarking. And now (after starting writing this) the biggest Firefox process is approaching 4GB -- after doing nothing but posting this and pretty fast (15-20 minute increase from 3GB to 4GB). Memory use seems odd to say the least. Most of the Firefox processes are under 500MB RAM use, which is where they all were when I started with maybe 3-4 going above that but most still around 600MB -- only one just over 700MB then the big one at 3.6-3.9 GB. Thunderbird is under 600MB then it's only Firefox processes (some but not all) that top 100MB each. Most things not Firefox and not Thunderbird are running around 50-60MB or below.
srs06
Posts: 11
Joined: October 18th, 2008, 7:28 pm

Re: Would love a setting to limit Firefox memory use

Post by srs06 »

srs06 wrote:
therube wrote:What CPU?
What are RAM/CPU usage numbers for your various programs when you run into this situation?

This is what I alluded to above, Not Enough Storage Space Is Available To Process The Command.
Pretty sure that only occurs pre-Quantum (as in I don't recall running it that situation with Quantum).
I don't get any error messages. Once in a while Firefox or Thunderbird will crash but that's rare. Mostly things just get extremely slow or totally unusable. If I wait long enough that will eventually clear, at least a bit.

One thing I notice is when the highest memory use Firefox process goes over 1GB, that's when it starts getting a lot worse. I looked at a recent case and I had over 45 tabs open (including several pinned tabs). So I tried increasing dom.ipc.ProcessCount to 50 to see what would happen. I ended up going a lot longer and for a long time no Firefox process hit the 1GB mark. Eventually though (today, after about 24 hours) the biggest Firefox process was up around 3GB and total RAM use was under my total of 24GB but over 22GB. Same thing even after closing tabs and closing the bookmarks window (which seems to sometimes make a decent difference). It's usable at that 22GB plus level but it can go almost to a stop if I try starting a new app. Right now there are around 40 tabs or a little less open, whereas right after I made that dom.ipc.ProcessCount increase it ran for many hours at about half the RAM use (right around 11GB total for a long time). I understand some of this is probably what's in a specific tab ... it would be great if memory use per tab could somehow be examined. But there are also only about 5 new tabs open over what I had yesterday -- but after closing about 10 I didn't need and won't be bookmarking. And now (after starting writing this) the biggest Firefox process is approaching 4GB -- after doing nothing but posting this and pretty fast (15-20 minute increase from 3GB to 4GB). Memory use seems odd to say the least. Most of the Firefox processes are under 500MB RAM use, which is where they all were when I started with maybe 3-4 going above that but most still around 600MB -- only one just over 700MB then the big one at 3.6-3.9 GB. Thunderbird is under 600MB then it's only Firefox processes (some but not all) that top 100MB each. Most things not Firefox and not Thunderbird are running around 50-60MB or below.
I just let it sit -- was not on the computer and now, about 2 hours later the largest Firefox process has ballooned to over 6GB -- more than three times the size of where it started and more than twice the size when it already seemed to be out of control. Total RAM use is now over 23GB, creeping toward the full 24GB I have. That would seem to indicate some bug in the way memory is allocated and used since it's growing huge without even using the computer.
srs06
Posts: 11
Joined: October 18th, 2008, 7:28 pm

Re: Would love a setting to limit Firefox memory use

Post by srs06 »

About three hours later, after again being away from the computer, the largest Firefox process was 7-8GB and almost all the RAM on my machine was now used. Again, this is just while sitting idle -- over the course of several hours the largest Firefox process grew from under 2GB to around 8GB. I finally closed Firefox to see the effect. After a few minutes for all processes to stop, the machine was back down around 7.5GB in use, which is about what I'd expect with everything else running. On restart of Firefox, CPU use spiked a bit as expected and when all tabs were connected, total RAM use settled in around 11.5GB or a bit higher. That's in line with what I always see. After a bit of use, then sitting overnight for 6-7 hours, I'm at about 12.5GB used on the computer. Largest Firefox process is just under 650MB.
kerft
Posts: 585
Joined: January 30th, 2019, 9:38 am

Re: Would love a setting to limit Firefox memory use

Post by kerft »

There are debugging tools for memory use mentioned in these articles https://support.mozilla.org/en-US/kb/fi ... memory-ram http://kb.mozillazine.org/Reducing_memo ... _-_Firefox
In addition to about:memory, about:performance will say which tabs are using high CPU and memory.
Blocking scripts on a page can make some pages more efficient, with Noscript or YesScript2. Blocking video or disabling autoplay on most sites can help. If the built in disable autoplay settings are insufficient, Ublock origin has a feature to "block media elements larger than XX KB" which will block video on most pages, and click the second icon on the bottom row to toggle it on or off on a particular page.
Post Reply