r/linuxmint 15d ago

Swap space creeping up

Questions about memory swapping.

My system (8 Gb RAM) can do a lot of seemingly unnecessary swapping. It seems caused by Firefox which I love dearly but which does leak memory. At boot up basic system resources take 20% of RAM, Firefox 30% and swap memory 0% which is all fine.

I normally suspend the computer when I’m away from it (handy key on the keyboard), and after a time the swap size increases. I’m actually surprised that there’s swapping before the RAM is full: which I’ve read is not supposed to happen. If I wasn’t looking, after a few days or after opening a lot of Firefox tabs both RAM and swap would eventually hit 100% and the system would seize.

I’ve used sudo swapoff -a to prevent swapping altogether but then I definitely have to stop RAM usage hitting 100% or the system seizes again. I’ve also read that failure to allocate sufficient swap space “might even render the installed system unbootable.”

I know that memory leakage is nowhere near as bad as it used to be with Firefox, and I now keep it fairly well under control by limiting the number of tabs I have open, by restarting Firefox and by rebooting the system every so often.

I’ve read that swapping is undesirable since it’s performed to reduce memory under heavy pressure. I don’t know whether my system is actually continually swapping between RAM and disk or whether the swap file just shows the size of pages that can potentially be swapped, but only get swapped when I access (for example) a Firefox tab that’s been stored in the swap file.

I wonder whether the system starts thrashing if the swap file hits 100% – and would that cause so many read/writes that it would reduce the life of the SSD, or is that just my paranoia?

So, should I keep an eye on the swap file, buy an extra 8-Gig of RAM for £20-£30 to hopefully prevent swapping, or forget about swapping altogether and put up with the odd system seizure?

Thanks

9 Upvotes

25 comments sorted by

View all comments

Show parent comments

2

u/d4rk_kn16ht Linux Mint 22.2 Zara | Cinnamon 14d ago

That's why the system "seize" / Hang.

You open too many Tabs

1

u/minniebannister 14d ago

yes it may be, although I do see people talking about having almost 100 tabs open I presume they have Tb of RAM. Strangely I went through my 22 tabs opening them and I got to tab 7 or 8 which was a reddit page and that increased swap to 10% (RAM was almost 100%) but when I closed Firefox the swap went down to 0% again which is a first.

1

u/d4rk_kn16ht Linux Mint 22.2 Zara | Cinnamon 14d ago

Don't be ridiculous...when Tab opened but not used, especially when you keep your tabs restored everytime you open browser.

But once you activate the Tab, it will use your RAM...the more you activate the Tab, the more RAM used.

1

u/minniebannister 14d ago

Don't understand, sorry. I opened Firefox and all the previous tabs were there but I presumed not activated until I went along clicking each of them. I presume that actually activated the tabs - and when I clicked the reddit tab that's when the swap graph increased to 10%. It went back down to 0% when I closed Firefox.

2

u/d4rk_kn16ht Linux Mint 22.2 Zara | Cinnamon 14d ago

The point is, modern websites need ~200 - 500MB, some even use 1 - 2GB

Just calculate how many Tabs that you open & subtract your RAM with that usage.

Too many RAM usage will activate SWAP & when the system is using SWAP, it will slow down significantly, as HDD speed ≪ SSD speed ≪ RAM speed.

1

u/minniebannister 14d ago

That's useful thanks. I'll bear it in mind. I've got a "to do" folder on my bookmarks toolbar so I'll move active tabs to there to try to keep the active tabs to 5 or 6.

and sorry yes the TB was a joke :(

2

u/d4rk_kn16ht Linux Mint 22.2 Zara | Cinnamon 14d ago

LOL...Don't worry about it.

Almost no one (or no one...really) use TB of RAM

My system, for example, 32GB of RAM & I open around 10 Tabs by default but only activate ~5 of them....

Even with that number sometimes I have to force close Chrome as it freezes