Allocating and monitoring virtual memory can be a challenge in server virtualization environments, but there are
different ways to address these issues. The Dynamic Memory feature in the upcoming Microsoft Hyper-V R2 Service Pack 1 includes virtual memory settings to help administrators allocate memory with greater precision.
Hyper-V Dynamic Memory makes virtual memory management even easier by providing constraints for the host's memory allocation behavior. To help you monitor virtual memory, Hyper-V's Manager Console provides information about the memory levels of each virtual machine (VM).
With Hyper-V Dynamic Memory, the host simply adds memory to VMs that need it and removes memory from those that don't. This memory allocation process works great -- as long as there's enough memory to go around. But if a Hyper-V host runs out of memory, it's forced to remove memory from VMs that need it. This puts the affected VM in an out-of-memory condition and memory pages are swapped to disk, which drastically drains performance. Fortunately, the Hyper-V Manager Console includes two new reports to help you monitor virtual memory settings and avoid a negative memory state.
Monitoring virtual memory in Hyper-V
The Manager Console keeps you informed of VM memory levels. You can use the Current Memory and Memory Available reports to monitor virtual memory and prevent VMs from experiencing negative memory. These columns provide data on the quantity of memory that has been assigned to each VM at any point in time. Because Hyper-V rebalances memory among VMs every second, you'll generally see the values in these columns updating at around that rate.
The Current Memory report gives you an absolute value of assigned memory. This value will increase as VMs' memory requirements increase, and decrease as needs decrease.
Slightly more interesting is the column marked Memory Available. Recall that the Hyper-V Dynamic Memory virtual memory settings let you reserve a percentage of additional memory as a memory buffer on each VM, in case the memory requirements change between one-second intervals. In a healthy system, the memory available value should be close to the percentage you've set for the VM's memory buffer. This is because Memory Available reports the percentage of memory currently available to the machine as compared to the total memory assigned to the VM at that moment.
As you can imagine, it's possible for this value to drop below zero. When Memory Available shows a negative value, it means that the host has given a particular VM less memory than it needs.
That's when a VM will page to disk to keep running. To prevent this negative memory state, your choices are limited. Your first option is to power down one or more VMs. Powering them down frees the memory balancer of each VM's memory requirements, possibly providing the host with enough total memory to move those values into the positive. Another option with similar results is to perform a live migration of a VM to another host. In the virtual memory settings, you can also limit the maximum amount of memory one or more VMs can reserve by reducing their configured maximum RAM values. A fourth option is to just add more physical RAM to the host.
Hyper-V Dynamic Memory can indeed create these painful situations, but they are more likely to happen when you haven't planned or monitored your infrastructure carefully. Hyper-V Dynamic Memory makes memory allocation more precise with its virtual memory settings, but you need to monitor virtual memory levels to make sure your hosts always have enough memory to go around.
Greg Shields is an independent author, instructor, Microsoft MVP and IT consultant based in Denver. He is a co-founder of Concentrated Technology LLC and has nearly 15 years of experience in IT architecture and enterprise administration. Shields specializes in Microsoft administration, systems management and monitoring, and virtualization. He is the author of several books, including Windows Server 2008: What's New/What's Changed, available from Sapien Press.