Hyper-V Dynamic Memory - virtual machine memory usage and host memory demand do not make sense

6,399

The Integration Components you installed when you built your VM included a driver which removes memory from the VM when that memory isn't needed. The way it removes it is that it allocates it from the memory manager within the guest OS and then gives it back to Hyper-V. It then looks, from within the VM, like it's "in use" because it has been allocated. This is referred to generally as "ballooning" and most hypervisors can do it, and even some physical systems do this too, using memory compression engines in hardware.

Share:
6,399

Related videos on Youtube

Orion Edwards
Author by

Orion Edwards

I do .NET, Ruby, Rails, PHP, and Snowboarding :-) @borland

Updated on September 18, 2022

Comments

  • Orion Edwards
    Orion Edwards almost 2 years

    I have a Hyper-V 2012 R2 server running a number of virtual machines with Dynamic Memory enabled. They all exhibit this behaviour, but here is an example:

    One of the VM's is a Windows Server 2012 R2 guest, and it's not doing much. Basically sitting there idling. It was doing a lot of work (it had launched a number of processes which allocated a bunch of memory, used some CPU, and then quit), but has now completed.

    Task manager inside the VM shows the following memory statistics:

    • In Use: 5.5 GB
    • Available: 302 MB
    • Committed: 5.6/6.9 GB
    • Cached: 299 MB

    The "Memory Composition" graph says that 5629 MB is "In Use" by applications, drivers, etc (i.e. it's not being used as file system cache). I've also run perfmon and the counters there line up with the task manager ones.

    Switching to the list of processes in task manager inside the VM, there is nothing using anything close to 5 GB of memory. Summing them all up comes to well under 1 GB.

    For more information, Hyper-V manager on the host system shows that this VM has

    • Assigned Memory: 706 MB
    • Memory Demand: 593 MB

    This fits with the memory usage I get by summing up the process list in task manager in the VM.

    So the question is:

    Why does task manager inside my VM think that it is using 5.5 GB, when no processes appear to use this memory, and the Hyper-V host knows that it only needs 593 MB? What has happened?

  • TomTom
    TomTom over 10 years
    Except being factually wrong. When you run a smart guest (Server 2012 R2) then the drive ractualyl removes the memory from being SEEN by the OS.... the amount of total memory changes dynamically. No joke - it is quite funny to see a VM's available memory (task manager, resource view) to increase.
  • Orion Edwards
    Orion Edwards over 10 years
    @TomTom - both the server and the guest are Server 2012 R2, so it should be a "smart" guest. I've seen the guest memory go UP, but I've never seen it go down... Interesting
  • Jake Oshins
    Jake Oshins over 10 years
    TomTom, I'm quite certain about how it works. (The guy who wrote the code is sitting two doors down from me at the moment.) Adding of memory beyond the "startup" value does, in fact add new memory to the VM. That memory can't be removed from Windows entirely, at least not without causing all the device drivers to be rewritten. So it's ballooned.