Hyper-V Memory

With Hyper-V’s “knobless” design, the biggest thing you have to remember about managing Hyper-V’s memory is to not try to assign more to virtual machines than you actually have available in your host. That’s not to say that you can’t find some room for tweaking.

Single Role

The first rule about Hyper-V is to not install anything inside the parent partition that isn’t directly related to Hyper-V or the hardware it lives on. Part of that is for security, but for the purpose of this discussion, it’s about resource contention. Any applications within the parent partition have to share resources with Hyper-V and all the guest machines. As a general rule, that contention is on equal footing; Hyper-V can’t prioritize itself over other applications operating at the same level. Make absolutely certain that everything in the parent partition is absolutely essential.

Design Virtual Machines

Spend some time in the design phase of your virtual machines thinking about how your Hyper-V memory is to be allocated. Memory is not to be wasted under any circumstances. Microsoft Exchange and most editions of Microsoft SQL are going to use up as much RAM as you assign to their virtual machines, so follow sizing guidelines for those applications to ensure that you are not allocating more than is actually needed for your projected workload.

Dynamic Memory

Microsoft introduced “Dynamic Memory” with Service Pack 1 for Hyper-v R2. This technology works by only assigning a minimum amount (that you specify) of RAM to a virtual machine at startup. Working through the Hyper-V Integration Services, a Windows virtual machine that supports hot add memory can dynamically request and release RAM as its needs fluctuate. Hyper-V is the arbiter of how these requests are granted or denied. You can adjust the properties on individual virtual machines to increase or decrease their weighting in case more RAM is being requested than is available.

Only recent Windows guests can use Dynamic Memory. Linux, Windows XP, and other guests that cannot communicate with the Hyper-V Integration Services’ hot-add driver will never use more memory than is set as the minimum. However, because Hyper-V does not validate that the guest system is hot add capable, it will at least attempt to set aside any specified buffer amount, causing that RAM to be completely wasted.

As previously mentioned, Exchange and SQL will generally just gobble up whatever they can, which makes dynamic memory sort of pointless. Editions of SQL that don’t support h0t add memory won’t be able to allocate anything beyond whatever the startup RAM is, and that bar is unfortunately high. In SQL 2005 through 2008 R2, Express and Standard Editions couldn’t use hot add memory. In SQL 2012, this capability has been granted to the Standard Edition as well, but still not to Express. You will definitely need to manually size these installations.

As a general rule, I do not employ Dynamic Memory. I spend the time to size each virtual machine. For those that might have fluctuating workloads that can justify using Dynamic Memory, I am careful to spend time setting their memory prioritization.

Hyper-V Memory Prioritization

You can use Hyper-V Manager to set weights on how memory is allocated to individual virtual machines. Look on the Hyper-V memory tab of a virtual machine’s properties. By default, they are all given equal weighting. If you aren’t using Dynamic Memory, the weighting only applies when virtual machines start up. If there is insufficient available memory to start a particular virtual machine, it is simply left off. If you are using Dynamic Memory, memory is allocated in your preset priority order from high to low. If all machines are the same priority, Hyper-V decides.

Dynamic Memory Weight

Basic Mechanics of Hyper-V Memory Utilization

Hyper-V does not “overcommit” or “thin provision” memory. Whatever RAM a virtual machine is reporting that it has access to is actually allocated to that machine and you cannot instruct Hyper-V to assign a greater total of RAM to virtual machines than you actually have available. Hyper-V will never page the RAM of its guest machines. In Hyper-V R2, this opens the door for some tweaking of the way the parent partition utilizes its page file; we produced an article outlining how to modify this. In Hyper-V 2012, the default page file configuration is much more suitable to the Hyper-V role and doesn’t really need any modifications.

If you want to see how memory is being utilized by Hyper-V itself, including how it has allocated memory to virtual machines, you’ll need a third-party tool. Task Manager won’t do it. This is because what you actually have access to is a parent partition, not the actual hypervisor itself. Task Manager won’t have access to anything other than what’s inside the parent partition, and that is nothing more than a special-case virtual machine that operates at the same level as any other virtual machine. Hyper-V Manager can show you how much memory is currently allocated to individual virtual machines, but doesn’t have any sort of totalling system. System Center Virtual Machine Manager can show you how much memory the host has available.

Memory Changes in Hyper-V 2012

The biggest news is the addition of “Smart Paging”. This is a pseudo-overcommit technology in which Hyper-V will temporarily page RAM for virtual machines under specific circumstances. Aidan Finn has already written a great summary of this technology. While reading that post, also take note of the change to the way .BIN files are handled in Hyper-V 2012. This addresses an annoyance to many Hyper-V R2 administrators who didn’t expect to lose those extra few gigabytes of storage space.

 

Altaro Hyper-V Backup
Share this post

Not a DOJO Member yet?

Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!

Leave a comment or ask a question

Your email address will not be published. Required fields are marked *

Your email address will not be published.

Notify me of follow-up replies via email

Yes, I would like to receive new blog posts by email

What is the color of grass?

Please note: If you’re not already a member on the Dojo Forums you will create a new account and receive an activation email.

Microsoft 365 Security checklist - free eBook