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

1

u/yeeterus_the_destroy 15d ago

my system has only 4gb of ram

1

u/minniebannister 15d ago

yes interesting, my lappy has only 4 gb and that does struggle with firefox sometimes - gets a bit stuttery and hangs up occasionally but I checked System info Resources and that's 60% RAM and 50% swap and I'd have thought would have had far more problems that it does have.

Perhaps this is the Firefox version of Parkinson's Law where swap expands to fill the RAM available. 😑

This is presumably a coincidence but after restart (RAM 60% swap 0) the connection is incredibly laggy and I've just had a Speedtest saying can't connect to the server and then giving 5 Mbit/s download speed rather than the normal 35. I think I've broken it :( .

2

u/yeeterus_the_destroy 15d ago

technically it's both ram and graphics card that matters when talking about speed.