Linux – Memory Ballooning in Linux/Unix on VMware ESXi

linuxmemoryunixvmware-esxi

I need help to reclaim the ballooned memory in a Linux/Unix machine. Please help me out. I found some solutions but they are not feasible for me on the production server.

I just need to know how can I reclaim the ballooned memory without rebooting or moving the machine to another host.

Best Answer

Ballooning only happens under some very specific conditions. For VMware ESXi to "inflate" the balloon driver in a VM, the host must be under very heavy memory contention, commonly less than 4% of free memory on the host.

The idea with the balloon driver is for VMTools to start consuming memory inside the VM, to which the OS of the VM responds to by giving the balloon driver memory pages. The balloon driver doesn't actually need these pages for anything, but it tells the hypervisor which memory pages the VM doesn't actually use for anything, so they can be safely discarded by the hypervisor. If this doesn't solve the memory contention problem on the host, the hypervisor continues to inflate the balloon driver, up to 65% percent of the assigned virtual memory by default, which causes the OS on the VM to start swapping to disk. This is not a great outcome, but it's a lot better than the hypervisor swapping to disk instead as the OS on the VM actually knows what pages makes sense to swap to disk.

The way to limit ballooning is to either turn it off per VM (not a great strategy), or to reserve memory for a VM. If a VM has say 4 GB of RAM and a 3 GB memory reservation, the balloon driver can only inflate to 1 GB.

As ballooning is a bit of a last ditch strategy for ESXi, it almost always means that you have too little memory installed on your host.