In Part 1 we covered Understanding Dynamic Memory in Hyper-V 2012/R2.
Today’s post will show Dynamic memory in Action :)
So let’s get started…
We have a Virtual Machine here set with 2GB as Startup RAM, minimum 512MB and maximum is 4GB RAM.
What can I see right now, this is actually been assigned with 640MB that actually shrunk from the startup amount 2GB.
If we actually look inside the guest Operating System in Task Manager, what we can see is it still thinks it has 2GB because you can’t really take memory away from the virtual machine.
What happens is that balloon driver (kernel device driver) tells the OS give me some memory, and that basically balloons driver consumes that memory, and then tells the Hypervisor hey, here is the memory block you can take this back :)
We can’t directly look at that, but with the RAMMap tool from Sysinternals can show that the Driver Locked is consuming around 1.5GB, which is roughly the difference between 2GB startup and the amount that actually is allocated right now (615MB + Memory buffer).
But this Virtual Machine can actually grow up to 4GB Maximum RAM, so what I want to do is going to apply some memory pressure to this Virtual Machine.
Let’s consume Physical Memory…
What this actually is doing putting it under pressure.
If we look at the Hyper-V is assigned that full amount 4GB :), as you can see now and it is in a Warning state because the memory demand actually want this amount [4,423MB].
When we cancel the memory pressure, the memory won’t be reclaimed straight away. You can see now is demand dropped right down, so now we have a huge amount of free memory.
If we look at the balloon driver and refresh, note that the driver locked basically went away, because that balloon shrunk right down and effectively reclaimed that memory from Hyper-V and gave it back to the Operating System.
What will see is, eventually a cleanup will actually happen and now it’s need this amount + 20%.
Will see the Assigned Memory will dropped and that balloon driver locked will actually go up again.
Give it some time… Going back to the guest OS and refresh, you can see all that memory is now assigned to the Driver Locked cause that balloon driver took it and the Hypervisor reclaimed it.
Now note the memory will always stays @ 4GB because you can never truly take memory away as far as the Operating System is concerned, it is still thinks it has 4GB but out of that a huge chunk of it is being consumed by this greedy Kernel device driver :)
Hope this has been useful.
Until next time… Enjoy your day!