Vmware has developed some of the best memory handling techniques. It allows to overcommit memories to certain extent but still run the virtual machines with no problem. The techniques used by VMware by are
Transparent Page Sharing
You can read about the memory handling techniques in various vmware articles. A found a very good article here. Memory Compression is the last resort of avoiding transfer of memory pages to swap-file which is located on the disk.
Transparent page sharing doesnt work with Guest OS that support 2MB pages as there is very little chance that memory pages of that much size will be same in two or more VMs. So when the VM memory gets full the pages are swapped out to the SWAPFILE. Now before swapping the pages are broken into 4kb chunks and a hash is calculated.
When about to swap the file to the disk the file is compressed and stored in memory. A certain area of memory is reserved for compression. By default only 10%. The point for compression and decompression is that the pages compressed are stored in the RAM even the decompression time is faster than the access from the disk file. The memory compression cache you can say is the last resort for memory management. If 50% compression is not reached then the pages are not compress and straight away sent to the disk. The compression format is GZIP.
Now as the VM memory grows more the compressed pages are also swapped out.
How to ENABLE OR DISABLE memory compression cache
Select ESXi host -> Configuration -> Under Software Settings -> Advanced settings -> MEM-> MemZipEnable
The value of 1 means it is enabled. Setting the value of 0 will disable the memory compression cache.
How to Configure the size of compression cache.
Select ESXi host -> Configuration -> Under Software Settings -> Advanced settings -> MEM-> MemZipMaxPct
The 10 % is the deafault value. It means 10% of the Virtual Machine Memory can be used for compress.
Some Other points :-
- There is no pro-active compression of memory pages in vsphere esxi.
- Compression uses 2-3% of host C.P.U. time.
- Time for compression is 20 MicroSecond 1i>