Freigeben über


Hyper-V 2012 Dynamic Memory: What does the VM think it has versus what it really has

On Wednesday, my teammate Chris Avis posted a very nice article on his blog about Monitoring Dynamic Memory in Windows Server 2012 Hyper-V.  Towards the end of the article, Chris makes a good observation that the counters you will likely spend the most time monitoring (specific to Dynamic Memory) are:

Hyper-V Dynamic Memory Balancer –> Average Pressure – This will allow you to see what the average available memory is at the host level over a period of time. This is great for establishing a baseline and continued monitoring over time to determine if workloads need to be shifted or more memory should be added to the host.

Hyper-V Dynamic Memory VM –> Average Pressure, Maximum Pressure, Minimum Pressure – These will allow you to look at the memory performance of individual VM instances. Again to establish a baseline as well as ongoing monitoring for future optimizations.


Although that may be true, I wanted to also point out two more items that may be of interest when trying to figure out what is actually presented to the VM as the amount of memory it has versus how much physical memory is actually assigned to it. These are counters you will likely look at periodically, but is still of interest as you start to really pack the VMs onto your Hyper-V hosts.

Hyper-V Dynamic Memory VM –> Guest Visible Physical Memory – This will show the amount of memory visible to the VM (What it thinks it has)

Hyper-V Dynamic Memory VM –> Physical Memory – This will show the current amount of memory in the VM (What it actually has)

I will use a VM named DC1 to explain what is going on and why.

First, the Virtual Machine Settings for DC1 are as shown:

dc1settings

I also brought up the Memory tab for the DC1 VM and the Performance Counter view for Physical Memory and took a screenshot of both tools.

physical memory

You can see that the Physical Memory counter mirrors the Assigned Memory displayed in Hyper-V Manager (yellow highlight). It’s also good to know what the maximum memory that was assigned to the VM (green highlight). This is very useful as you look at sizing of VMs and sizing of your Hyper-V hosts for the VMs you plan to run on them. Please keep in mind that these values are for the window of time that you are collecting the data. 

In my case, the Assigned Memory is at 1602 MB which is also the maximum for the real-time windows I’m looking at.

A common “mistake” many people make is to assume that the assigned memory is also what the Guest OS in the VM sees. This is NOT the case. Assuming the VM is not already consuming the Maximum memory per the VM Settings, Hyper-V will “tell” the VM it has more memory available that is actually assigned. In the below screenshot that shows Guest Visible Physical Memory, you can see that in my case, the VM thinks it has 1798 MB of RAM. Let’s say in the middle of the night, my VM is pretty much not doing anything and the Assigned Memory were to drop to 1024 MB, the Guest Visible Physical Memory may still be at 1798 MB. Unless there is really a reason to adjust this up or down, Hyper-V will leave this setting alone for performance reasons. If you think about it, this does make sense as there’s no reason to keep adjusting the memory visible to the VM just because it isn’t using it. If Hyper-V did do that, it would consume more cycles on the Host and would also impact performance of the Guest OS in the VM (ever so slightly) because it would adjust itself as well.

guestvisible

I hope this provides a little more insight into Dynamic Memory for you and gets you thinking more about how you can monitor and plan for memory use in Windows Server 2012 Hyper-V with Dynamic Memory.

Harold Wong