Go to ...

RSS Feed

Hyper-V, Virtual RAM and Virtual CPUs

Quite a number of IT pros and advanced users alike use virtual machines to test Windows Insider builds, to run legacy operating systems for intermittent needs, to have a sandbox environment to test new software, or for a myriad of other reasons. My choice for virtualization software is Hyper-V, and has been since it was included in the consumer version of Windows 8.

There are two things to consider when creating a virtual machine to assure it will run properly: first, the amount of virtual RAM (vRAM from here on) and second, the number of virtual processors (vCPU). Both of these give you some choices.

Assigning vRAM you can elect if you use dynamic RAM giving VM minimum and maximum values for assigned RAM which it then takes and frees from host RAM according to its needs. Selecting the count for vCPUs lets you choose the number of virtual processors, where the maximim count is restricted on Windows 10 hosts by the hardware setup and by Non-Uniform Memory Access (NUMA). For more information about NUMA please consult: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/dn282282(v=ws.11).

For instance, if I try to add more than 4 vCPUs to virtual machines on this laptop, I get an error message that in my case, four vCPUs is maximum:

Virtual RAM

As a concept, dynamic RAM  is pretty nice. The VM uses the amount of RAM it needs within assigned minimum and maximum values, taking more from the host RAM when it needs it and freeing it when it’s no longer needed. However, the VM will be and is a bit slow in demanding more RAM when it needs it, which causes issues when you want to launch a process or program that needs more RAM than is currently allocated.

I very strongly advice against selecting and using dynamic RAM for Hyper-V VMs. It is OK if the VM will never be used to anything else than simple browsing and email, but it is not recommended for “work horse” virtual machines. For example: A Windows 8.1 PRO VM in Hyper-V with dynamic RAM, minimum set to 1 GB, maximum 4 GB. When idle, it uses less than 2 GB:

Trying to run a program that requires more RAM that is currently available, or which has a built-in check for minimum RAM for program to run whose requirements exceed currently allocated RAM, you will get an error message. The following screenshot shows what happens if you try to run a Windows 10 upgrade on the previously described Windows 8.1 VM:

Alas, the VM sends the demand for more vRAM to the host too late, or as in the case of this VM and a Windows upgrade, it does not demand it at all. Thus, the upgrade can’t be completed without first switching the VM off and either increasing minimum dynamic vRAM or changing to fixed vRAM.

This is just one simple example. You can of course “trick” the VM to temporarily increase the amount of vRAM by slowly opening various programs demanding more and more vRAM until VM has enough to do the task required, then close those apps and rapidly start the process requiring all that vRAM, but it is much more efficient and in fact time saving to set VM not to use dynamic vRAM in the first place and instead assign it a fixed (and sufficient) amount of vRAM to work with.

How much vRAM should I assign to a VM?

It depends. The rule of thumb (read: my rule!) is to always leave the host at least 2 GB available RAM. Using this laptop of mine as an example, I have 16 GB of RAM. When Windows 10 PRO installed on it has booted to desktop, and I have my chosen browser Edge opened with six or seven tabs, I usually have about 11 GB free. To assure that there will be at least 2 GB free available RAM on host at any given time, I can in other words simultaneously use virtual machines that consume a total of 9 GB of vRAM:

Total RAM 16 GB - RAM host is using to run smoothly 5 GB - 2 GB reserve = 9 GB.

A Windows 10 x64 VM runs really smoothly when it has 3 GB. On the other hand, based on my own experience a VM used for instance for video editing requires 5 GB or more. Yes, that’s right, no typos there: 3 GB and 5 GB! Somewhat surprisingly, I’ve noticed that we IT pros are so accustomed to RAM amounts as 1 GB, 2 GB, 4 GB, 8 GB and so on that we tend to forget that in Hyper-V, you really can set the amount as you wish with increments of 1 MB. Hyper-V accepts any amount of vRAM above the required minimum. If you want to assign a VM 5673 MB it’s totally OK, as would be 1789 or 3197 MB.

Personally, my Linux and Windows XP virtual machines get 512 MB to 1 GB, Windows 7 and 8.1 virtual machines 1 GB to 2 GB, and Windows 10 virtual machines 3 or 4 GB, exception being my video editing VM which gets 6 GB.

Virtual CPU

One host CPU core can support 8 virtual CPUs. Let’s take a look of this laptop of mine:

Four cores, meaning the theoretical maximum of vCPUs to be used at any given time is 32. Of course I cannot assign all these 32 vCPUs to be used at the same time because then the host would be left without any resources, and that system, including both the host and all of its virtual machines would halt. When deciding how many vCPUs a VM gets, we must think about how many VMs we will be running at the same time. In any case I do not want to use more than half of my host CPU resources for virtual machines. Assigning four vCPUs to each VM, I can be sure that I can quite smoothly run three or four virtual machines at any given time, subject to having enough RAM.

My recommendation is to use four vCPUs on each VM with a quad core host CPU, and scale it according to your host CPU. No issues in running virtual machines on dual core CPU host, but in that case I would not give more than two vCPUs per VM.

Hyper-V Quick Create

By default, Quick Create assigns 2 GB of vRAM to each new VM. If / when using Quick Create, please check the settings and change vRAM amount as required before launching the new VM.

I use and recommend you to use Quick Create to create your own VM repository as told in this earlier post of mine. In my case, I use it to create a new repository after each Windows 10 semi-annual feature upgrade. Using for instance my current version 1803 repository, I can quickly create a new VM selecting from four languages and all editions of Windows 10 whenever I have a need to check or test something.

That’s it this time geeks! Possible questions in comments, please.


Author: Kari Finn

A former Windows Insider MVP, Kari started in computing in the mid 80’s writing code for VAX / VMS systems. Since then, he’s worked in a variety of IT positions. He specializes in Windows image capture, customization, repair and deployment as well as Hyper-V virtualization. Kari is a proud Team Member at number #1 Windows site TenForums.com.

3 Responses “Hyper-V, Virtual RAM and Virtual CPUs”

  1. CountMike
    June 23, 2018 at 09:31

    I use VMware almost exclusively now, number of vCOREs and memory are set as necessary but always 1GB of RAM per vCore as that’s some minimum for physical machines.
    This host machine has more than enough resources to assign half of them and still have more than enough left for host OS.
    Most Linux distros and XP are happy with 2C/2GB. W7 4/4 and for W10 that’s minimum and depending what I’m doing I usually set 8/8.
    The only thing I never checked (tnx. for reminder) is how many threads of each core is actually engaged. This CPU has 2 threads per core and show in Windows 16 “processor” count.

  2. One very useful enhancement in Hyper-V on 2016 and 10 is the ability to change static memory at runtime – you can have a machine running with a certain _fixed_ amount of memory, and change that fixed amount while the VM is live. So you can get the benefits of both a smaller fixed amount moment to moment, but increase for the times when you need to increase. This is of course not as “cool” as dynamic, but it avoids the issue you mention of dynamic not picking up on demand appropriately. (cf. https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/what-s-new-in-hyper-v-on-windows#BKMK_hot )

  3. June 25, 2018 at 16:02

    That is true. I have almost completely given up using dynamic vRAM and use static instead, modifying the amount “on the fly” as needed.

Leave a Reply