Does anyone know how to initiate the garbage collection and memory reduction in Firefox (about:memory
> Free memory > GC/CC/Minimize memory usage) from the terminal? This browser is using way to much RAM and I found that clicking on "Minimize memory usage" actually cuts the load by about 20-30%. Unfortunately, this doesn't last very long, but my idea is to create a Bash script and cron
it.
-
Check this: support.mozilla.org/en-US/kb/… Note that an extension could be the one eating up memory. I limited the number of concurrent (content) Firefox processes in very old computers and memory issues stopped.– Eduardo TrápaniCommented Aug 9, 2020 at 23:11
-
1Good question. It's frankly ridiculous these browsers don't manage their memory better by default.– Time4TeaCommented Aug 10, 2020 at 10:51
-
@EduardoTrápani: Thx, unfortunately, it's the same with all extensions disabled and I already reduced the content process limit from 8 to 1...– davidCommented Aug 10, 2020 at 15:31
-
1@Time4Tea: Yeah, right? Isn't this also a security issue? Also, what reason would a browser have to use that much resources apart from (voluntary or involuntary) "distributed computing applications"? It feels like I'm permanently donating basically half of my PCs computing power to the browser xo– davidCommented Aug 10, 2020 at 15:33
-
I run Firefox Nightly on a pretty old computer from 2008 and there are no memory issues. Could your expectations be wrong? I mean, the gap between the memory you think should be used and the one actually used? Do you experience memory issues? (since you are trying to manage memory directly). If you are running short on memory, swapping too much, etc, and you want to solve it you could ask a new question to see what happens to your particular Firefox instance. Please do state the browser's version and operating system.– Eduardo TrápaniCommented Aug 10, 2020 at 15:53
|
Show 2 more comments
1 Answer
This can only be "automated" by opening a new tab and clicking the button which would be difficult to do but possible e.g. using xdotool
or xvkbd
, see:
If I were you, I'd instead use cgroups to limit Firefox RAM usage:
systemd-run --user -t -p MemoryMax=1500M firefox
This command works for me in Fedora 32.
Here's how you can run it from a shortcut:
cat firefox.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Firefox RAM Limited
Exec=systemd-run --user -t -p MemoryMax=1500M firefox
Icon=firefox
Terminal=false
StartupNotify=false
-
3Hi, the last option seems very interesting. Do I have to apply the
systemd-run
options to all Firefox "child processes" (e.g.WebExtensions
andWeb Content
) or is it sufficient to limit the main process (firefox-bin
)?– davidCommented Aug 10, 2020 at 15:35 -
Also, will this option take care if there are multiple instances (e.g. there are usually 2-3 instances of WebExtensions)? And is the syntax for
systemd-run
case-sensitive, i.e. will it still work if I dosystemd-run --scope -p MemoryLimit=500M webextensions
forWebExtensions
? Thx a lot ^-^– davidCommented Aug 10, 2020 at 15:55 -
PS.: Btw, what would be the syntax to apply the options to multiple processes? Would this work:
systemd-run --scope -p MemoryLimit=200M firefox-bin MemoryLimit=200 WebExtensions MemoryLimit=500M Web Content
(and do I need to escape blank spaces)?– davidCommented Aug 10, 2020 at 16:09 -
1Doing
systemd-run --scope -p MemoryHigh=500M /opt/firefox/firefox
opened a new Firefox window - is this setting permanent or do I have to open Firefox every time using the command?– davidCommented Aug 10, 2020 at 22:18 -
1What happens if the process attempts to write to more memory than the limit? Does Firefox try to minimize its usage automatically or does it just crash?– bfrguciCommented Jun 15, 2022 at 19:50