| training | new training - Jon Welling
How to Configure VM Memory
How much memory do I need to give this virtual machine (VM), and how do I do that? That very question has kept even the best IT pros up at night. But it's time we change that. We need to band together and attack our IT anxieties head-on.
Today we are going to help you learn how to configure VM memory, how much memory you need to give to VMs, and how not to create memory performance issues in Hyper-V.
An Overview of How to Configure VM Memory
Understanding how to assign memory to a virtual machine is an essential skill for sysadmins who want to make their hardware more effective and efficient. In this video, James Conrad shows you how to configure and allocate memory for a virtual machine — and why it's essential to allocate the appropriate amount of memory for your applications.
How do I Configure VM memory?
Configuring virtual memory allocation in Hyper-V is an easy process. So, without further fanfare, let's get into it.
First, launch the Hyper-V Manager in Windows. The Hyper-V Manager is the primary administration snap-in component for the Windows OS. Note that these instructions are for Windows 10 Pro, Windows 11 Pro, and recent versions of Windows Server with a user interface. Bare versions, or the base version of Hyper-V, do not include any user interfaces and must be configured via the command line. In that case, the Hyper-V Manager can be used from another Windows machine to manage Hyper-V remotely instead, but that is an IT tragedy for a different story.
After opening Hyper-V Manager, select your VM cluster from the side panel.
Next, locate the VM that you need to edit. Depending on your environment, you may have lots of virtual machines. If this is a home lab, there's a good chance you only have a few VMs on hand.
After finding the virtual machine in question, right-click the VM and choose settings. This will launch the settings panel that has various settings for Hyper-V VMs. The settings that are accessible from this panel are only standard settings. There are a ton more options available if you configure Hyper-V through PowerShell.
In the settings pane, choose Memory. Pay attention to the first setting in the memory tab. This is where you set the target amount of RAM assigned to your VM. Adjust this setting and click Apply.
Adjusting the memory assigned to a VM in Hyper-V is as simple as that. We're not done, however. Nothing in IT is ever that easy, is it?
What is Dynamic Memory in Hyper-V?
Most hypervisors have something called dynamic memory, including Hyper-V. So, here's where life gets tricky. If you look under the Dynamic Memory area of the Hyper-V settings window, you'll notice a minimum and maximum setting. Hyper-V can adjust the amount of memory a VM uses in real-time. But, of course, things get muddy here.
The first setting you changed assigned the amount of memory a VM uses on startup. This is akin to a cold start on your computer. If you assign a VM 8Gb of memory, your VM will claim and use 8Gb of memory on startup. If you adjust the min and max memory settings to 8Gb, your VM will constantly claim and use exactly only 8Gb of physical memory.
That's not the wisest idea, however. Windows will use unused memory as cache space, but we don't need that in the VM world. We want to utilize our hardware to its fullest extent. Using unused memory for application cache is typically at the bottom of our list.
So, we'll set the min and max memory more appropriately. For instance, our minimum amount of memory might be set to 2Gb. A typical office-use PC typically doesn't drop below 2Gb of memory usage. We might also set the max memory to 16Gb. We don't want our end-users to keep opening apps and use all the physical memory a server is sharing between multiple VMs.
What is Memory Buffer in Hyper-V?
Next, there is an option for a memory buffer. Since Hyper-V needs to adjust the memory allocated and used by each VM constantly, sometimes it's good to give a specific VM a bit of buffer space.
For instance, if this VM is a mission-critical VM, you might want to give it a 30% buffer. That means the hypervisor will assign 8Gb of memory to the VM plus 30% just in case it needs it. That way, other greedy VMs don't come and take that valuable RAM space from our mission-critical virtual machine.
What is Memory Weight in Hyper-V?
Finally, we have a setting for weight. This setting states where this VM falls in the pecking order. If the VM is super important, it gets a higher weight. That way, the hypervisor knows whom to service first. VMs with a lower weight are considered second-class citizens and only get resources after VMs with a higher weight are taken care of first.
Assigning the correct amount of memory to your virtual machines is very important. The entire point of virtualization is to utilize more hardware while reducing TCO in the enterprise space. Virtualization is also a valuable tool for home labs. Nonetheless, if you assign too much memory to each VM, you will not be able to utilize your server hardware as best as possible. If you give too little memory to your VMs, you will have performance issues. Either way, you are going to have a bad time.
So, learn how to implement Hyper-V the right way. Hyper-V is a fantastic tool that also happens to be free. It's included with Pro versions of Windows, Server versions of Windows, and as a standalone bare-metal hypervisor.
After you learn how to get those VMs up and running, learn how to use PowerShell with Hyper-V and become a virtualization god/ess. You can do amazing things with Powershell and Hyper-V, including automating your entire VM environment and enabling sunset settings like RemoteFX (something that must be done through the command line).
Finally, learn how to cluster and replicate VMs in Hyper-V. All enterprise environments want both high availability as well as redundant systems.