I have 3 virtual servers on a host. The host has 320GB of ram.
I have 2 at 32GB and my SQL server at 256gb.
Since I won't be over committing RAM i have locked the Ram on all 3 servers.
However when I shutdown a VM and start it back up the swap file returns with the full size
of the RAM.
As you can imagine 320gb of disk that is not usable is a lot.
Please help me get my disk space back.
Did the VM go into a powered off state? The swap is created for a VM when you power it on, so it would need to be in an off state first.
Did you select reserve all guest memory? If this option is checked, a swap file should not be created.
In addition, after selecting reserve all guest memory, you need to turn the virtual machine on / off.
The VM was indeed shut down and I selected reserve all.
I think the issue was the maximum was set to unlimited. I made it match the allocated RAM and powered down again and this time it came back as 0 kb.
Should the maximum have to be set as well.
Selecting unlimited memory has nothing to do with the swap. The use of the memory limit option is slightly different. For example, you have assigned 128GB of memory to a virtual machine, and you don't want that virtual machine to exceed 64GB. In this case, you can limit it to 64GB.
However, if you give 128GB to a virtual machine, this virtual machine cannot exceed the 128GB limit. So it doesn't matter if it is unlimited or if you write 128GB in the limit section.