Hyper-V Dynamic Memory and Host Memory Reserve setting
My name is Nick Eales and I am a Premier Field Engineer based in Sydney, Australia. I specialize in Hyper-V and Failover Clustering.
Today I am writing about the following registry setting for Hyper-V’s Dynamic memory which was introduced with Windows Server 2008 R2 Service Pack 1
Registry Key: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization
Value Name: MemoryReserve
Value Type: REG_DWORD
(Value is set in decimal, and is in megabytes. It needs a reboot to take effect)
As Hyper-V can now dynamically allocate memory to virtual machines on demand, the host needs to ensure that some memory is kept for itself. This registry setting enables the amount of memory reserved for the host OS to be manually set for scenarios where the default is not appropriate.
There are many comments, blog posts, and articles around that suggest setting this value. Some state that the default is 32MB (very wrong). Recommended values range from 1024 to 2048.
I read a lot of these and as they all recommended that this value be set and I didn’t want to run into any problems on our team’s Hyper-V server, I had a go and set this value to 1024 (1GB).
A month later, I had a look at our Hyper-V server and found out it had 11MB of memory available. While VM’s were running relatively normally, the host OS was running extremely poorly, which was making management of the host very difficult. Hyper-V had allocated so much memory to the VMs, that it had starved the host (no memory for disk cache, many services were crippled, etc.).
I decided to do some more research on this value to find out why a non-default value is needed, and what the default value is.
In summary, for Hyper-V in Windows Server 2008 R2 SP1 the default value for this is calculated based on the following formula:
384MB + 30MB per 1GB of physical memory on the host machine.
(For a machine without SLAT (Second Level Address Translation) enabled CPUs, it is slightly higher)
So for my SLAT enabled Hyper-V server with 64GB RAM, this would mean the default value is:
Note: The above calculation only applies to Windows Server 2008 R2 SP1 / Hyper-V Server 2008 R2 SP1. Later operating systems use a very different calculation and we strongly suggest re-evaluating the need to change this setting from the default (to set it to the default, delete the registry value).
384 + (30 * 64) = 2304 (MB)
This explains why:
- Some sites suggest setting this value – on a machine with less than 32GB of RAM the default value would be too low to allow the machine to be used for other applications.
- Setting the value (as I mistakenly did) to a value significantly less than the default (eg 1024MB on a 64GB machine) might have a negative effect on performance
So my recommendation is as simple as;
- If (as per best practice) you use only Hyper-V on your servers and your drivers, backup, antivirus and other applications do not use a lot of memory, then leave this value at the default (i.e. it should not be present).
- If you run virtual machines at the same time as other applications or services (Outlook / Domain Controller), then calculate the default value for your machine, and add to this a number sufficient for your applications. Please note that by running other services and applications on the host, you will be non-compliant with Microsoft Hyper-V best practices.