Heard a question the other day in regards to changing virtual machine reservations on the fly and the resulting impact on the size of the swap (.vswp) file.
Every running virtual machine on a VMware ESX/i host has a .vswp file associated with it. The .vswp file is created when the VM is powered on and removed when it is powered off. By default it is the same size as the configured/allocated memory for the VM (vRAM).
The .vswp file is used in the event that the host is actively over-committed (more active memory in use than the host has physically). In that instance the host will start swapping VM vRAM from the host’s physical memory into the vswp file just like normal OSes do when you run them out of memory.
There are several mechanisms in place (transparent page sharing, ballooning/vmmemctl, memory compression) to enable over committing without hitting the swap file, but I just want to demonstrate how the .vswp is created and sized.
One more concept – Reservation. A reservation is a guarantee of physical resources. If you reserve 256MM of RAM on a guest with 512MB of RAM you are guaranteeing that the guest will always have access to 256MB of physical RAM on the host.
Combining the two concepts, setting a 256MB reservation on a guest with 512MB of RAM means you will never swap more than 256MB out to the .vswp file. Powering on this VM will result in a .vswp file of 256MB.
Ok, so what happens if you change the reservation on the fly?
If you increase the size of the reservation, the .vswp will not decrease in size until you power-cycle the virtual machine.
If you decrease the size of the reservation, the .vswp file *will* increase on the fly tho it is not always immediate.
Swap file is created at power on, removed at power off
Swap file size = Allocated minus Reserved
Swap file size will increase on the fly as reservation is reduced
Swap file size will not decrease as reservation is increased (new size will take effect at next VM power cycle)