PVE is using all swap with lot of RAM available

agapitox

Renowned Member
Dec 3, 2008
24
1
68
Zaragoza, Spain
We have several nodes, where swap consumption is high, but they have a lot of free ram.

If I do a: swapoff -a && swapon -a, it frees correctly but after a few days the problem returns.

To what point is this normal?
 

Attachments

  • Captura de pantalla 2021-03-26 a las 10.25.26.png
    Captura de pantalla 2021-03-26 a las 10.25.26.png
    129.2 KB · Views: 6
  • Captura de pantalla 2021-03-26 a las 10.25.01.png
    Captura de pantalla 2021-03-26 a las 10.25.01.png
    128.8 KB · Views: 5
Is it actually a problem? If you have a lot of disk I/O from the VMs, Linux will prefer to use the memory for file cache and buffers and push less often used memory to swap. Linux will not start pulling it from swap back to memory by itself unless there is actual demand for the memory stored in swap. Therefore, if you really have 8GB of memory that is allocated but not used, it will slowly move towards swap and stay there.
If you want Linux to read back all the swapped memory instead of using that memory file cache use the swapoff;swapon trick. Changing vm.swappiness in /etc/sysctl.conf can also be used to change this balance between more cache and less swap usage, but swap will still grow unless the swapped memory is requested again by applications.
 
Last edited:
  • Like
Reactions: lDemoNl

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!