Virtual memory in virtualized machines (Swap File in VM?)

I'm not a virtualization expert (in fact I think it's the wrong tool for the job most times), but from what I have read your guest OS's should not be allowed to swap. The primary reason for preventing swapping is it represents a way for one guess OS to hog a large portion of th e host's IO bandwidth.

Also, you don't want to pretend to your guess OS's that the host has more physical memory than it has as it will cause the host to swap heavily, but debugging performance issues inside the guess OS's will be very hard, because from their point of view they are not swapping, and none of the os level tools in the guest will show it.

It may even be with tools like Xen and VmWare you cannot overcommit memory on the host OS because of the use of baloon memory drivers.


That would heavily depend on the consequences of overcommitting memory on your host OS. I would be a bit more than annoyed if, for example, I'd have the Linux out-of-memory killer slay my virtual machine. I tend to set aside a smaller, separate, preallocated, snapshot-independent (if applicable to your VM solution) virtual disk for each guest OS, ensure the file hosting that disk image is not fragmented and/or on a fast drive, and configure the guest swap space to reside on that virtual disk. Hypervisor memory management today is good enough to not feel the difference between OOM host swapping and OOM guest swapping, and I can fine-tune guest behavior independently. Best of both worlds.