Firefox uses all the memory and mint hangs

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Firefox uses all the memory and mint hangs

Post by mailak »

Firefox uses all the memory and mint hangs every ~2 days.
7.5GB ram, Mint 21.1
How to limit memory usage for firefox?
Last edited by LockBot on Wed Sep 20, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: Firefox uses all the memory and mint hangs

Post by Cosmo. »

Some more information is needed, starting with the system specs; at now we know nothing.
Open in the menu -> system report -> system information -> click the copy button; paste in your next post.
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Re: Firefox uses all the memory and mint hangs

Post by mailak »

System:
Kernel: 5.15.0-56-generic x86_64 bits: 64 compiler: gcc v: 11.3.0 Desktop: MATE 1.26.0 wm: marco
dm: LightDM Distro: Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy
Machine:
Type: Laptop System: LENOVO product: 23923QG v: ThinkPad T530

What is it needed for?
I think that memory limitation method does not depend either this is Lenovo or not!
altair4
Level 20
Level 20
Posts: 11460
Joined: Tue Feb 03, 2009 10:27 am

Re: Firefox uses all the memory and mint hangs

Post by altair4 »

Firefox gives you a couple of tools that will at least tell you which tab or process is using the most memory.

Type in the location bar one of these:

Code: Select all

about:performance

Code: Select all

about:processes
And they are dynamic so if you open a new tab for instance it will show up as a new line in the "performance" query.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
zcot
Level 9
Level 9
Posts: 2838
Joined: Wed Oct 19, 2016 6:08 pm

Re: Firefox uses all the memory and mint hangs

Post by zcot »

So, likely you are going through many tabs. And if you go for days, then you can just periodically close firefox, open it again and select settings -> history -> restore previous session. -that will deactivate the tabs although they will be there and will activate when you click them.
motoryzen
Level 10
Level 10
Posts: 3489
Joined: Sun Dec 08, 2019 12:25 am

Re: Firefox uses all the memory and mint hangs

Post by motoryzen »

mailak

What cosmo mean was...

1. Press that start button aka Windows Logo button on your keyboard, type without quotes " system reports"
2. click the "System information" button on the upper left, copy button on bottom right
3. come back and and paste.

This does'nt give any personally identifiable info but gives much more than what you posted. The mods of this site put that how to get help link above for good reason..to save time on speculation. By posting the info requested you speed things up.

I"m not saying you didn't try, but give it another shot
Mint 21.2 Cinnamon 5.8.4
asrock x570 taichi ...bios p5.00
ryzen 5900x
128GB Kingston Fury @ 3600mhz
Corsair mp600 pro xt NVME ssd 4TB
three 4TB ssds
dual 1TB ssds
Two 16TB Toshiba hdd's
24GB amd 7900xtx vid card
Viewsonic Elite UHD 32" 144hz monitor
User avatar
zcot
Level 9
Level 9
Posts: 2838
Joined: Wed Oct 19, 2016 6:08 pm

Re: Firefox uses all the memory and mint hangs

Post by zcot »

The system info is really not required here. -enough info is available to tailor an answer, or don't answer, it's pretty clear. We can go off on a tangent, sure, or just at least give a good start as a base effort, or don't. -do it for the post count if you want to. :lol:
Petermint
Level 9
Level 9
Posts: 2983
Joined: Tue Feb 16, 2016 3:12 am

Re: Firefox uses all the memory and mint hangs

Post by Petermint »

In a 4 GB machine with Firefox, I shut Firefox and the OS down completely overnight. Masses of Web browsing did not fill 4 GB in a day. The next day started fresh and clean.
* I also added NoScript to block the Javajunk and the OS + Firefox rarely passed 2.6 GB.
* I did not watch big videos in the Web browser.

What sites do you visit? How many tabs open? Any add-ons?
tenplus1
Level 1
Level 1
Posts: 34
Joined: Wed Nov 02, 2022 9:00 am

Re: Firefox uses all the memory and mint hangs

Post by tenplus1 »

Personally I go into about:config and change these settings to help memory use in Firefox:

browser.cache.memory.enable (false)
browser.cache.disk.enable (false)
browser.cache.offline.enable (false)
network.prefetch-next (false)
browser.sessionhistory.max_total_viewers (0)
browser.sessionhistory.max_total_viewers (1500000)
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Re: Firefox uses all the memory and mint hangs

Post by mailak »

tenplus1
What are these settings for?
I made the following changes:
browser.cache.memory.capacity -1 --> 102400
network.prefetch-next true --> false
browser.sessionhistory.max_total_viewers -1 --> 4
browser.sessionhistory.max_entries 50 --> 5
Pages many different incl. gmail, youtube and facebook

System:
Kernel: 5.15.0-56-generic x86_64 bits: 64 compiler: gcc v: 11.3.0 Desktop: MATE 1.26.0 wm: marco
dm: LightDM Distro: Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy
Machine:
Type: Laptop System: LENOVO product: 23923QG v: ThinkPad T530 serial: <superuser required>
Chassis: type: 10 serial: <superuser required>
Mobo: LENOVO model: 23923QG serial: <superuser required> UEFI-[Legacy]: LENOVO
v: G4ETA7WW (2.67 ) date: 08/24/2016
...
CPU:
Info: dual core model: Intel Core i5-3210M bits: 64 type: MT MCP arch: Ivy Bridge rev: 9 cache:
L1: 128 KiB L2: 512 KiB L3: 3 MiB
Speed (MHz): avg: 2536 high: 2735 min/max: 1200/3100 cores: 1: 2482 2: 2735 3: 2372 4: 2557
bogomips: 19955
Flags: avx ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3
Graphics:
Device-1: Intel 3rd Gen Core processor Graphics vendor: Lenovo driver: i915 v: kernel ports:
active: LVDS-1 empty: DP-1, DP-2, DP-3, HDMI-A-1, HDMI-A-2, HDMI-A-3, VGA-1 bus-ID: 00:02.0
chip-ID: 8086:0166
Device-2: Acer ThinkPad Integrated Camera type: USB driver: uvcvideo bus-ID: 1-1.6:5
chip-ID: 5986:02d2
Display: x11 server: X.Org v: 1.21.1.3 compositor: marco v: 1.26.0 driver: X:
loaded: modesetting unloaded: fbdev,vesa gpu: i915 display-ID: :0 screens: 1
Screen-1: 0 s-res: 1600x900 s-dpi: 96
Monitor-1: LVDS-1 model: Lenovo res: 1600x900 dpi: 118 diag: 396mm (15.6")
OpenGL: renderer: Mesa Intel HD Graphics 4000 (IVB GT2) v: 4.2 Mesa 22.0.5 compat-v: 3.1
direct render: Yes
...
Sensors:
System Temperatures: cpu: 48.0 C mobo: N/A
Fan Speeds (RPM): fan-1: 1973
Repos:
Packages: apt: 2040
No active apt repos in: /etc/apt/sources.list
Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list
1: deb http: //packages.linuxmint.com vera main upstream import backport
2: deb http: //archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
3: deb http: //archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
4: deb http: //archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
5: deb http: //security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
Info:
Processes: 291 Uptime: 6d 34m Memory: 7.47 GiB used: 6.4 GiB (85.7%) Init: systemd v: 249
runlevel: 5 Compilers: gcc: 11.3.0 alt: 11 Client: Unknown python3.10 client inxi: 3.3.13


I use mobile internet from a cellular phone.
Could be somehow also max memory used by firefox limited i.e. to ~2-4 GB?
Having ~7.5GB of memory, I would like to have some memory for other processes even if FF uses all allowed.
billyswong
Level 8
Level 8
Posts: 2230
Joined: Wed Aug 14, 2019 1:02 am

Re: Firefox uses all the memory and mint hangs

Post by billyswong »

If you don't install any ad-blocker or script-blocker extension to Firefox, leaving it open overnight will engulf a lot of RAM easily. Shut it down before sleep then use session restore to pick things back up is necessary to prevent hang if you want to stay generous to advertisement companies and their memory hogging spying code.
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Re: Firefox uses all the memory and mint hangs

Post by mailak »

Hi,
I use AdBlocker Ultimate
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Re: Firefox uses all the memory and mint hangs

Post by mailak »

Additionally changed command to:
systemd-run --unit=my-firefox --user --scope -p MemoryHigh=2G -p MemoryMax=3G -p MemorySwapMax=1G firefox %U
Don't know what are parameters: systemd-run --unit=my-firefox --user --scope
The only problem is that firefox doesn't "remember" tabs which were opened.
How to solve it?
billyswong
Level 8
Level 8
Posts: 2230
Joined: Wed Aug 14, 2019 1:02 am

Re: Firefox uses all the memory and mint hangs

Post by billyswong »

mailak wrote: Tue Apr 04, 2023 4:18 pm The only problem is that firefox doesn't "remember" tabs which were opened.
Method 1 (once):
≡ > History > Restore Previous Session
Method 2 (always):
≡ > Settings > General > Startup > Open previous windows and tabs

Or do you mean Firefox launched by your command can't restore session?
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Re: Firefox uses all the memory and mint hangs

Post by mailak »

Method 2 seems to be working. I had this setting chosen previously that's why I didn't check it before.
Method 1 > History > Restore Previous Session didn't work at all
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Re: Firefox uses all the memory and mint hangs

Post by mailak »

Finally changed Firefox settings to this:
systemd-run --unit=my-firefox --user --scope -p MemoryHigh=2.5G -p MemoryMax=3G -p MemorySwapMax=0.5G firefox %U
But anyways sometimes firefox is not much responsive (which is still much better than laptop hard reset and other applications are working properly).
Maybe Firefox is not the best browser possible.
How to set similar settings to chromium? Are settings like below good and correct? What would you recommend regarding chromium?
chromium --disable-gpu %U
systemd-run --unit=my-chrome --user --scope -p MemoryHigh=2.5G -p MemoryMax=3G -p MemorySwapMax=0.5G chromium %U
ivar
Level 5
Level 5
Posts: 617
Joined: Sun Mar 21, 2021 10:30 pm
Location: far north

Re: Firefox uses all the memory and mint hangs

Post by ivar »

billyswong wrote: Sun Apr 02, 2023 9:29 am If you don't install any ad-blocker or script-blocker extension to Firefox, leaving it open overnight will engulf a lot of RAM easily.
found the same here, enventually both memory and swap fills up and makes things sluggish. Stopping/restarting FF usually clears out the hogged RAM, but I often have to reboot to get if to flush all my swap
Machine: i5 gen4 , 4 GB ram, 6,5 GB swap. uBlock Origin to stop ads
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Re: Firefox uses all the memory and mint hangs

Post by mailak »

What I found is that firefox is good until it gets problems and hangs.
Chromium (Chrome for Linux) seems to be working much better.
Suggested solution is not to use firefox at all but use Chromium instead!
I start Chromim with parameters as below. Not sure either it makes sense but recently Chromium works well.
systemd-run --unit=my-chrome --user --scope -p MemoryHigh=2.5G -p MemoryMax=3G -p MemorySwapMax=0.5G chromium %U
mailak
Level 1
Level 1
Posts: 18
Joined: Fri Feb 04, 2022 3:27 pm

Re: Firefox uses all the memory and mint hangs

Post by mailak »

Update:

Setting for Chromium:
systemd-run --unit=my-chrome --user --scope -p MemoryHigh=3.5G -p MemoryMax=3.5G -p MemorySwapMax=0G chromium %U

Setting for Firerox:
systemd-run --unit=my-firefox --user --scope -p MemoryHigh=2.0G -p MemoryMax=2.0G -p MemorySwapMax=0G firefox %U
Main browser is Chromium.
User avatar
stevengarland
Level 5
Level 5
Posts: 843
Joined: Tue Mar 05, 2019 4:04 pm
Location: Michigan

Re: Firefox uses all the memory and mint hangs

Post by stevengarland »

Easy to limit tabs with XTab. I only allow 4 and have no problem.
Keep It Simple Sweetheart
Locked

Return to “Beginner Questions”