Whenever I leave Firefox on, with a bunch of tabs, for more than a few hours, its memory use balloons, and everything else seems to be swapped out, so my system becomes highly non-responsive. In a typical case, it will have a child process named WebExtensions which takes up 27 GB of virtual memory. I think it might be this bug:
Very high virtual memory usage in the WebExtensions process on Linux
but I'm not sure. Anyway, my question is: What can I/should I do to either make Firefox leak less memory; hard-limit the amount of virtual memory it uses; or as a last resort, auto-restart it when it hits a certain memory use threshold?
Information about my system:
- Firefox 83.0
- Devuan GNU/Linux Beowulf (= Debian Buster without systemd)
- Kernel: Linux 5.10.0-0.bpo.3-amd64 (bundled with Devuan)
- Physical RAM: 16 GB.
- Output of
topfor the two relevant processes (not while experiencing the non-responsiveness; hmm...):PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 9616 eyalroz 20 0 26.7g 310316 142716 S 5.6 1.9 8:32.19 WebExtensions 9472 eyalroz 20 0 3845772 1.0g 322156 S 0.0 6.6 27:26.37 firefox-bin
2 Answers
I'd probably say to use an addon to unload the tabs after an amount of time.
I have been using Auto Tab Discard to "sleep" tabs and reduce memory usage. It will simply unload the tabs, free up memory and halt any scripts that may be using memory or the CPU. You can configure the timeout or manually trigger sleep on all tabs other than the one you are looking at.
You can also whitelist tabs that you never want to be put to sleep. Tabs that are sleeping will have a đź’¤ emoji applied for this particular addon.
Selecting the tab will immediately reload the tab, from experience it is mostly instant with some slight reloading.
4The memory leak might be in some extension, rather than in Firefox itself.
To check, start Firefox in Troubleshoot/Safe mode, by the menu entry Help, then "Troubleshoot Mode…" and click "Restart".
If the problem disappears, locate the troublesome extension by selectively
disabling extensions in about:addons.