Q. Does the memory amount I see in a guest virtual machine (VM) using Dynamic Memory reflect the true amount of physical memory currently allocated to it?

John Savill

July 25, 2010

2 Min Read
ITPro Today logo in a gray background | ITPro Today

A. Dynamic Memory giveth and it taketh away to enable the best distribution of memory between VMs, depending on their workloads at different times.

When a VM starts, it's allocated the amount of memory that is defined for its Startup RAM amount (when Dynamic Memory is used). If the VM's available memory drops below the desired available memory buffer percentage, the VM will be allocated more RAM, based on the RAM available on the Hyper-V host (i.e. not already allocated to other VMs) up to the Maximum RAM value for the VM.

If you close applications in the VM and it now has extra memory available above the buffer percentage, and if other VMs need the memory or Hyper-V decides to reclaim it after a long period of not being used, the balloon driver in the VM (which is a kernel device driver, so if it asks for RAM the OS has to give it) will be requested to grow by the Hyper-V management process. The guest reports back the memory addresses allocated for the balloon driver to Hyper-V, and Hyper-V can then allocate those physical pages to another VM (because it knows the balloon driver isn't actually using the memory).

The guest OS doesn't know it has lost memory, it just knows it gave a chunk to a device driver. So if you look at the total memory in the VM, you'll see the high water mark value of memory—basically, the most memory it has ever been given since it was turned on—as you can see here.

This shows the VM thinks it has 3205MB of memory, but in fact, it only has 1589MB of physical RAM actually allocated to it. The balloon driver is consuming the other roughly 1600MB of memory.

If the VM comes under memory pressure again and the Hyper-V host has spare memory available, it will tell the balloon driver to release a certain portion of the memory allocated to it, and Hyper-V will remap those released pages back to physical RAM, so other processes can use it.

The amount of memory you see in the VM may not be the true physical RAM it currently has been allocated by Hyper-V. It's the most physical RAM it has ever been allocated since being started.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like