This is an old desktop I use for some small self hosting services. I never use all my RAM and I don’t see any RAM spikes other than when I install/compile things which I haven’t done in months. I restarted the machine a couple of times, but the SWAP will eventually go right back up to 100%.
I have an Ubuntu server/yunohost setup and found: https://askubuntu.com/questions/157793/why-is-swap-being-used-even-though-i-have-plenty-of-free-ram
My cat /proc/sys/vm/swappiness
value is indeed 60. Im not sure what would reduce the SWAP space usage.
Would changing this swappiness value help? Anyone come across this issue before?
EDIT: Found out what it is, its the matrix server that is running on the system. Its taking up a significant amount of swap. Found out via:
smem -s swap -r -p
turning that off, the system is now using 90% less SWAP.
/opt/yunohost/matrix-synaps
was the process.
Depending on what your server is doing, swap use is normal. But if it’s into swap cuz ram is full, you will find it grinds to a halt.
Use
free -mh
to see what the memory use is, there is a way to reduce the swapiness if your running a database server and is advised.And how does cache space figure in to this? I have a server with 64GB of RAM, of which 46GB is being used by system cache, but I only have 450MB of free memory and 140MB of free swap. The only ‘volatile’ service I have running is slapd which can run in bursts of activity, otherwise the only thing of consequence running is webmin and some VMs which collectively can use up to 24GB (though they actually use about half that) but there’s no reason those should hit swap space. I just don’t get why the swap space is being run dry here.
That’s how Linux manages it memory, it will use free memory as file cache till it needs it. Then free up memory for process use.
If your only half using the memory for actual services, you may want to reduce it.
But why doesn’t it ever empty the swap space? I’ve been using vm.swappiness=10 and I’ve tried vm.vfs_cache_pressure at 100 and 50. Checking ps I’m not seeing any services that would be idling in the background, so I’m not sure why the system thought it needed to put anything in swap. (And FWIW, I run two servers with identical services that I load balance to, but the other machine has barely used any swap space – which adds to my confusion about the differences).
Why would I want to reduce the amount of memory in the server? Isn’t all that cache memory being used to help things run smoother and reduce drive I/O?
All I can tell you from my decades of Linux use is, the memory management is very odd.
But yes more free memory should help keep things running shooth, if you have the memory leave it as is
Why would it do anything with the swapped-out pages if they are never subsequently accessed?
Paging them back in for no reason is not an effective use of CPU time or system memory.