Back in the early days of Windows, the pagefile was used primarily to make up for insufficient RAM. At the time, RAM was very expensive, and swapping memory pages between the pagefile and the RAM helped reduce costs. Since that time, of course, memory has become far more affordable. This begs the question of whether or not the pagefile is still needed, especially in the case of Hyper-V virtual machines.
There are compelling arguments both for and against the use of a pagefile, and I’m not sure that there is a universally acceptable answer. Even so, I wanted to give you a few things to think about when deciding whether or not to use a pagefile with Hyper-V virtual machines.
Pagefile role has changed
One of the biggest arguments against using pagefile is that you don’t need it as long as Windows has plenty of memory. However, it is worth noting that the role of the pagefile has changed a bit over the years. While a pagefile can still be used to make up for physical memory shortages, that isn’t its primary purpose anymore. Instead, a pagefile is used to support system crash dumps.
It is also worth noting that there are certain Windows Server roles that actually require a pagefile to function properly. These include Windows Server domain controllers, Distributed File System Replication servers, Windows Servers that are acting as a certificate authority, and ADAM / LDS servers.
The reason why these servers require access to the pagefile is because of the way that they use the Extensible Storage Engine. This database engine, which is also used in Microsoft Exchange Server, needs to release memory if that memory is requested by other processes running on the server. When that happens, the pagefile is used to store a copy of the data residing in those memory pages before they are released.
So do you need to use a pagefile in a Hyper-V environment? According to Microsoft, Hyper-V needs to have the parent operating system’s pagefile set to System Managed. When it comes to Hyper-V virtual machines, however, things aren’t quite so cut and dried.
Let’s suppose for a moment that you have a virtual machine that is not running any of the previously mentioned services. Just to make things interesting, let’s forget about crash dumps for the time being and focus solely on memory. Assuming that the virtual machine has been allocated plenty of RAM, you should theoretically be able to get around the need for having a pagefile. However, as a general rule, it’s a good idea to leave the pagefile enabled (and set to System Managed) if the virtual machine uses dynamic memory.
This is because dynamic memory is designed to allocate memory to virtual machines based on memory pressure. In other words, a virtual machine that is under a heavy workload and that is requesting additional memory might take that memory from another virtual machine that is sitting idle and not using all of the memory that has been allocated to it. While this sounds good in theory, it is unlikely that a virtual machine is sitting idle and can easily give up a portion of its memory in the real world. While Hyper-V usually does a good job of juggling the available memory among the virtual machines that are dynamically using it, the process of moving RAM from one virtual machine to another isn’t always instantaneous. In these types of situations, Windows can temporarily use the pagefile until it gets the RAM that it needs.
Allocating memory to VMs: A balancing act
Of course, allocating memory to Hyper-V virtual machines is something of a balancing act. Suppose you allocate too much memory to your Hyper-V virtual machines. In that case, some of that memory will likely be unused, and you may end up decreasing the total number of virtual machines that your Hyper-V host can accommodate. On the other hand, allocating too little memory to a Hyper-V virtual machine causes performance problems and increased CPU and storage use.
So, how can you tell if you have allocated the correct amount of memory to a Hyper-V virtual machine? There are three performance monitor counters that you can use to tell whether a virtual machine is under memory pressure and needs to have more memory allocated to it.
The first of these counters is Memory – Standby Cache Reserve Bytes. This counter’s value will vary depending on how much memory is allocated to the virtual machine. If a Windows virtual machine has only been allocated 1GB of RAM, this counter should reflect a value of 200GB or more. If the virtual machine has at least 2GB of RAM, the value needs to be at least 300GB. A lower value indicates that the virtual machine is under memory pressure and could benefit from additional RAM.
The second Performance Monitor counter you should be watching is the Memory – Free & Zero Page List Bytes. As was the case with the Memory – Standby Cache Reserve Bytes, systems with 1GB of RAM need to show a value of at least 200MB, and systems with 2GB or more of RAM should display a value of at least 300MB.
The third Performance Monitor counter that is worth watching is the Memory – Pages Input / Sec counter. Unfortunately, this counter’s value fluctuates a lot, so you can’t just take a glance at the counter’s current value. Instead, Microsoft recommends taking the average value over at least an hour. The average value needs to be less than 10.
So, pagefile enabled or disabled? It depends
As a general rule, it’s usually best to leave the pagefile enabled for your Hyper-V virtual machines. Even so, there are situations in which disabling the pagefile may be justified.
Featured image: Shutterstock