I get asked frequently, what is the difference between the Consumed Host Memory of a VM (shown in the VM Resources), and the Active Guest Memory. This explanation is technical, but answers the question correctly.
Consumed Host Memory usage is defined as the amount of host memory that is allocated to the virtual machine.
Active Guest Memory is defined as the amount of guest memory that is currently being used by the guest operating system and its applications.
But here is the technical aspect of it all:
1) Why is consumed host memory usage higher than active guest memory?
“The hypervisor knows when to allocate host physical memory for a virtual machine because the first memory access from the virtual machine to a host physical memory will cause a page fault that can be easily captured by the hypervisor. However, it is difficult for the hypervisor to know when to free host physical memory upon virtual machine memory deallocation because the guest operating system free list is generally not publicly accessible. Hence, the hypervisor cannot easily find out the location of the free list and monitor its changes.”
So the host allocates memory pages upon their first request from the guest (that’s why consumed is less than the configured maximum), but doesn’t deallocate them once they are freed in the guest OS (because the host simply doesn’t see those guest deallocations). If the guest OS re-uses such previously allocated pages, the host won’t allocate more host memory. If the guest OS however allocates different pages, the host will also allocate more memory (up to the point where all configured memory pages for the specific guest have been allocated).
2) How is active guest memory calculated?
“At the beginning of each sampling period, the hypervisor intentionally invalidates several randomly selected guest physical pages and starts to monitor the guest accesses to them. At the end of the sampling period, the fraction of actively used memory can be estimated as the fraction of the invalidated pages that are re-accessed by the guest during the epoch”.
In other words, the active guest memory is calculated from outside the guest by an approximation on the hypervisor level.