In my earlier discussion, I talked through configuring virtual machines on a Hyper-V host to support Dynamic Memory. Now I will talk about how Dynamic Memory looks within a virtual machine and how the Dynamic Memory allocations look within the Hyper-V administrator console.
Take note that Dynamic Memory is only supported if the Guest Operating System is “aware” of Dynamic Memory. At this time, Windows Server 2008 R2, Windows Server 2008 with SP2, Windows Server 2003 with SP2, Windows Vista with SP1 (Enterprise and Ultimate) and Windows 7 (Enterprise and Ultimate). The Hyper-V Dynamic Memory Evaluation Guide has the additional detail, but basically all of the Server SKUs, Standard Edition and above, and the Professional Desktop SKUs support Dynamic Memory.
Let’s take a look inside the virtual machine with Dynamic Memory enabled. What does the user of the virtual machine see? You can see below that the Total Physical Memory within the virtual machine is 1281 MB. This virtual machine just stated up, so now we’ll start using the virtual machine and see what happens…
|This is a screen shot of task manager running within the virtual machine. Take note of the Total Physical Memory.|
As we start opening files and actually using the virtual machine, it’ starts to consume additional memory. Here is the view in Hyper-V manager (on the Hyper-V host) of this particular virtual machine. You can see that the Assigned Memory has increased from our initial 1118 MB to 1916 MB. This particular virtual machine is now consuming the resource it needs to meet the demands of the user.
Looking at Task Manager within the virtual machine, we see that the Total Physical Memory available has increased from the initial 1281 MB to 1713 MB. This shows how the available RAM within the virtual machine can dynamically grow as needed.
|Here is the same virtual machine later as I have started more applications within the virtual machine. Take note of the increase in the Total Physical Memory available to the virtual machine.|
Now we will reduce the the number of applications running on this virtual machine. As we start closing files, we start reducing the memory demand. We can see in task manager (within the virtual machine) that memory is being freed up, but just because the virtual machine starts reducing its memory demand does not mean that Hyper-V will immediately reclaim that available memory.
|Even though we’ve closed applications and reduced our memory demand, the Total Physical Memory does not decline.|
Hyper-V will eventually reclaim that available memory, but until there is a demand for the available memory, reclamation may take some time.
And a few minutes, Hyper-V starts the reclamation process and we can see that this virtual machine now only has 1204 MB of RAM assigned to it and the actual memory demand from the virtual machine is still declining.
Here is a screen shot (below) of Task Manager later in the day. The virtual machine still reports that is has 1915 MB of RAM available, even though Hyper-V manager (above) shows that there is only 1024MB of RAM assigned to this virtual machine. Windows supports hot-add of RAM, but it does not support hot-removal of memory. Hyper-V can still reclaim this 900 MB of RAM, it does this by leveraging memory ballooning. Memory Ballooning basically marks the memory to be reclaimed as “in use” in the guest virtual machine. The virtual machine views the reclaimed memory as “in use” so the virtual machine does not tamper with that block of memory. Now that the virtual machine cannot access that memory, Hyper-V is able to reassign that region of physical memory to another virtual machine. If this particular virtual machine needs additional RAM again, Hyper-V will first free up these spaces of “in-use” memory first and then Hyper-V will start adding additional memory if needed.
|Hyper-V will reclaim RAM as it becomes available and as other VMs demand additional RAM.|
As you can see, the great part about Dynamic Memory is that the end user is typically not even aware of the memory changes unless they look for them. From the end users’ perspective, they are able to use all of their applications and have all of the resources they need, on demand. From the administrators perspective, we can now rest assured that users will have the resources they need when they need them, without having to over allocate resources for peak scenarios.
Until next time,