Use of SWAP memory

It is recommended to use swap with HestiacP

Thanks

It depends ……

what does it depend on?

I have servers with 4 GB of RAM. But the SWAP memory is not released even though the RAM is at 0%

Thank you very much for your help Eris

Swap for +4 GB should almost not been used maybe for some memory intensive tasks… Unless you have ClamAV installed as it hogs memory…

For systems less then 2 GB it is always smart to add some…

This can be normal behavior and sometimes even wanted. 0% free memory doesn’t always mean that the server is out of memory. Have a look at free -h, there is a column named buff/cache

              total        used        free      shared  buff/cache   available
Mem:           3.8G        1.3G        1.4G        117M        1.2G        2.2G
Swap:          1.0G          0B        1.0G

Memory under buff/cache is actually free memory that can be used any time. Instead of not using the memory at all, the system creates some caches with it. But as soon as new processes need more memory, the cache is flushed and the memory gets released to cover the new needs.

Swap memory not being released is not a bad thing either (as far as I know). If data on swap is data that is rarely or never used, then it’s a good thing it is on swap memory. I guess noone wants rarely used data to just sit idle on RAM :wink:

Some articles I’ve studied, suggest to also configure the swapiness property. The below settings work well for me (but I always accept criticism and suggestions):

sysctl vm.swappiness=20
echo 'vm.swappiness=20' | tee -a /etc/sysctl.conf
sysctl vm.vfs_cache_pressure=50
echo 'vm.vfs_cache_pressure=50' | tee -a /etc/sysctl.conf

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.