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ápani Aug 9 '20 at 23:11
  • 1
    Good question. It's frankly ridiculous these browsers don't manage their memory better by default. – Time4Tea Aug 10 '20 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... – sarah.farrah Aug 10 '20 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 – sarah.farrah Aug 10 '20 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ápani Aug 10 '20 at 15:53

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]
Name=Firefox RAM Limited
Exec=systemd-run --user -t -p MemoryMax=1500M firefox
  • Hi, the last option seems very interesting. Do I have to apply the systemd-run options to all Firefox "child processes" (e.g. WebExtensions and Web Content) or is it sufficient to limit the main process (firefox-bin)? – sarah.farrah Aug 10 '20 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 do systemd-run --scope -p MemoryLimit=500M webextensions for WebExtensions? Thx a lot ^-^ – sarah.farrah Aug 10 '20 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)? – sarah.farrah Aug 10 '20 at 16:09
  • Thank you so much! – sarah.farrah Aug 10 '20 at 16:09
  • The systemd-run command will take care of all the child processes - they will all share the same RAM space. – Artem S. Tashkinov Aug 10 '20 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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