Windows Virtual Memory and Pagefile Size Configuration

In Windows, applications do not access physical memory (RAM - Random Access Memory) directly; each application uses the virtual address space that the operating system provides to it. For this reason, virtual memory is not a reserve that is used only when the RAM is full. It is always in use, even when there is enough RAM. The Windows memory manager decides which part of the data in the virtual address space stays in RAM and which part stays on disk. The space on the disk side is the paging file named pagefile.sys, referred to as the pagefile for short. When the memory demand of the running applications exceeds the available RAM, rarely accessed data is written to this file and is brought back into RAM when it is needed. Because a disk is considerably slower than RAM, the aim here is not to gain performance; the aim is to allow workloads whose memory demand exceeds the physical RAM to continue running.

Consider a concrete example. Assume that the system has 8 GB of RAM. When the total memory demand of the running applications exceeds this capacity, the applications would be expected to receive an out-of-memory error if there were no pagefile. At this point, the memory manager writes data in RAM that has not been accessed for some time to the pagefile and gives the freed RAM to the work that is running at that moment. When the data written to the pagefile is needed again, it is read from disk and brought back into RAM. One detail is important here: the data that goes to the pagefile is data that has been modified in memory. The code in the .exe and .dll files of an application is already on disk, so it is not written to the pagefile; it is read again from its own file when needed.

2 values determine how Windows allocates memory. The commit charge is the total amount of memory that the system has committed at that moment. The commit limit is the upper value that can be committed without growing the pagefile; it corresponds to the sum of the physical RAM and the current sizes of all pagefiles on the system. On a system with 8 GB of RAM and a pagefile that is 4 GB at that moment, the commit limit is approximately 12 GB. When the commit charge reaches this limit and the pagefile cannot grow any further, new memory requests cannot be met. If the system writes to and reads from the pagefile heavily because of memory pressure, increasing the pagefile size allows the applications to run but does not remove the slowness; in this case the permanent solution is to add physical RAM.

The sections below first explain why the pagefile is needed, where it is stored and what determines its size, and then the size is configured manually on Windows.

This article is not tied to a specific Windows version. The graphical steps here apply to Windows clients and to Windows Server installed with Desktop Experience; the part that changes between versions is the path to the Virtual Memory window. On Server Core installations, the same setting is configured from the command line or through remote management.

Is It Necessary to Use Virtual Memory?

The pagefile has 2 jobs in Windows. The first is to extend the commit limit. Windows allocates memory to applications by committing it, and it requires every committed memory area to be backed by RAM or by the pagefile. When the commit charge reaches the commit limit and the pagefile cannot grow, memory allocations fail; applications return errors, stop responding or close. The pagefile raises this limit and keeps the system running, especially with applications that request large amounts of memory and when many applications run at the same time.

The second job is to support the memory dump that is created when the system crashes. For the dump data to be written to disk during a BSOD (blue screen), a pagefile or a dedicated dump file of sufficient size must exist. For the Kernel, Automatic and Complete memory dump types, the default output is the %SystemRoot%\Memory.dmp file. For the Small memory dump type, a separate .dmp file is created for each crash under the %SystemRoot%\Minidump folder. If this space does not exist or is too small for the selected dump type, no dump file is created and it becomes harder to analyse the cause of the crash.

On systems with a large amount of RAM, the pagefile may not be needed to back the commit charge; physical memory may be enough on its own. Even so, turning the pagefile off completely has 2 consequences. The commit limit stays restricted to the physical RAM, and allocations fail when an unexpected memory request arrives. In addition, a memory dump cannot be taken if no dedicated dump file has been defined. For this reason, on general-purpose Windows systems the suitable default is to leave the pagefile enabled and managed by Windows.

On Windows Server, the pagefile requirement of the product or role that runs on the server takes priority. Roles such as domain controllers, DFS Replication, certificate servers and AD LDS need a pagefile. For Exchange Server 2019 and Exchange Server Subscription Edition, Microsoft requires the minimum and maximum pagefile size to be equal and set to 25 per cent of the installed memory. If such a requirement exists, the value in the product documentation is applied instead of automatic management.

Where Is the Virtual Memory File Stored?

On Windows operating systems, the pagefile is stored under the name pagefile.sys. By default, this file is in the root directory of the drive where the operating system is installed, which is the C:\ drive in most cases. Because it is a hidden and protected system file, it is not visible in File Explorer by default. To display it, select Show hidden files, folders, and drives and clear Hide protected operating system files on the View tab of the File Explorer Options window.

Windows decides by default which drive holds the file; however, depending on the need, the file can be moved to a different drive, spread across more than 1 drive, or sized manually. The choice of location affects both memory management and memory dump generation. For applications with a high memory requirement or in multitasking scenarios, the pagefile must be on a drive with enough free space so that the file can grow when needed.

If you remove the pagefile from the system drive completely, a memory dump may not be created after a BSOD, depending on the selected dump type. If you need dumps, leave a pagefile of sufficient size on the system drive or use a dedicated dump file.

How Can I Speed Up Virtual Memory?

The speed of the disk that holds the pagefile makes a difference when the file is accessed frequently and that disk cannot handle the incoming I/O load. In such a case, keeping the pagefile.sys file on a high-speed drive such as an SSD considerably shortens the time needed to read back the data written to the pagefile. On a system with enough RAM, where the pagefile is rarely accessed, the disk that holds the file makes no noticeable difference.

Another method is to move the pagefile to a physical disk other than the busy disk that holds the operating system, or to keep more than 1 pagefile on different physical disks to spread the I/O load. The deciding factor here is the physical disk; moving the file to another partition on the same disk does not spread the load, because the read and write operations still go to the same hardware. The gain from this approach is more noticeable on HDD-based systems; on modern systems with a single SSD, the difference stays limited.

Maintenance of the drive that holds the pagefile also affects access time. If you use an HDD, regular defragmentation of the drive improves file access. The Windows Optimize Drives tool recognises the drive type and performs maintenance accordingly; it applies defragmentation on HDDs and retrim on SSDs that support TRIM. You do not need to perform any additional manual operation for SSDs; it is enough to leave scheduled optimisation enabled.

All of these settings speed up access to the pagefile, but they do not bring the disk up to the speed of RAM. If the system writes to and reads from the pagefile constantly, the real solution is to reduce the need for the pagefile, which means adding physical RAM.

What Is the Recommended Virtual Memory Size?

For many years, a general rule of "Initial Size = RAM × 1.5, Maximum Size = RAM × 3" was used for the virtual memory size. These multipliers date from the Windows XP and Windows Server 2003 period. In those versions, the initial size of the pagefile managed by Windows was 1.5 times the RAM if the RAM was below 1 GB, and equal to the RAM if it was 1 GB or more; the upper limit was 3 times the RAM. Microsoft's current approach is not based on a fixed RAM multiplier; the pagefile size is determined by the peak commit charge of the system and by the required memory dump type. 2 systems with the same amount of RAM can have completely different pagefile needs, depending on the workload that runs on them.

In automatic mode, Windows sizes the pagefile at startup according to the dump setting and grows it during operation as needed. On Windows 10 and Windows 11, the pagefile is grown when the commit charge exceeds 90 per cent of the current commit limit and there is free space on the disk. The normal ceiling for this growth is the larger of 3 times the RAM and 4 GB, and it is also limited to 1/8 of the volume size. The only exception is the crash dump setting; if the dump requires it, Windows can exceed this limit and grow the pagefile until 1 GB of free space remains on the volume. In other words, the value of 3 times the RAM appears today not as a recommendation but as the growth ceiling of automatic mode.

On the memory dump side, the smallest pagefile size required varies with the selected dump type.

Dump Type Smallest Pagefile Size Required
Small memory dump 1 MB in Microsoft's 64-bit sizing document, at least 2 MB on the boot volume in the Windows Server dump document
Kernel memory dump Depends on the kernel's virtual memory usage; there is no fixed value
Complete memory dump Physical RAM + 257 MB
Automatic memory dump Depends on the kernel's virtual memory usage; with System managed size, Windows determines it and it can be smaller than the RAM

The default dump type depends on the installation. On Windows clients the default is Automatic memory dump; Microsoft's Server Core configuration document, however, gives Kernel memory dump as the default. An Automatic memory dump has the same content as a Kernel memory dump; the difference is that Windows can keep the file smaller than the RAM while the pagefile is in System managed size mode. If the system crashes and the pagefile is too small for the dump, Windows raises the lower limit of the file. If you want to take a Complete memory dump, the pagefile must be at least physical RAM + 257 MB.

On general-purpose Windows systems, the System managed size mode, which leaves the size to Windows, is the suitable default. Manual sizing is needed when a product or role document requires a specific value, when disk space is limited, or when a specific dump type must be guaranteed.

If you configure the size manually, your starting point must be your real memory usage. In Task Manager, the Committed field in the Memory section of the Performance tab shows the current commit charge and commit limit values. The part of the peak commit charge that exceeds the physical RAM, as seen when the system is at its busiest, is the amount that the pagefile must cover on the commit side; you can determine your values by adding a margin to it. The classic 1.5 and 3 times formula can still be used as a starting point when it is not possible to take measurements; Microsoft also recommends 1.5 times the RAM for the initial size when memory errors are caused by slow pagefile growth. On systems with a large amount of RAM, however, the upper limit of 3 times the RAM is larger than necessary in practice.

Disk space must also be taken into account. The maximum size is the ceiling up to which the file can grow, and that amount of space is not reserved in advance; the amount reserved on disk in advance is equal to the initial size. If the drive that holds the pagefile does not have enough free space left for growth, the file cannot grow, the commit limit does not increase, and additional memory requests cannot be met.

Configuring the Virtual Memory Size Manually

This section shows step by step how the virtual memory settings are reached and how the pagefile size is configured manually. As an example, the classic formula is applied on a system with 8 GB (8192 MB) of RAM: 12288 MB, which is 1.5 times the RAM, is entered for the Initial size, and 24576 MB, which is 3 times the RAM, is entered for the Maximum size. These values are an example of manual entry; on your own system, it is more accurate to determine them from the measurement described in the previous section and from the dump requirement.

Preliminary Checks

Before the configuration is started, the following items are verified.

Check Expected State
Permission The signed-in account is a member of the local Administrators group of the computer
Total RAM The total amount of physical RAM to be used in the initial size and maximum size calculation is known
Free disk space The drive that will hold the pagefile has enough free space to cover the initial size and to allow growth up to the maximum size, with the space used by the existing file also taken into account
Dump type The dump type selected under Startup and Recovery in the System Properties window is known, and the size to be entered covers this type

The total and available amount of RAM on the computer can be displayed from CMD (Command Prompt). To display the total amount of RAM:

systeminfo | findstr /C:"Total Physical Memory"

To display the available amount of RAM:

systeminfo | findstr /C:"Available Physical Memory"

Virtual Memory

The field names in the systeminfo output change with the language of the operating system. On a non-English Windows installation these filters return no result; in that case you can use the PowerShell command below.

To see the total capacity of the installed memory modules in MB, independently of the operating system language, the following command is run in PowerShell. The command adds up the Capacity value of each module; the usable memory reported by the operating system can appear slightly lower than this total because of the space reserved by the hardware.

[math]::Round((Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum / 1MB)

Step 1 - Opening the Virtual Memory Window

1- This PC is right-clicked, and then Properties is clicked.

Virtual Memory

In current versions of Windows 10 and in Windows 11, Properties opens the About page in the Settings app; the Advanced system settings link is also on this page. You can open the System Properties window directly by typing sysdm.cpl in the Run box.

2- In the window that opens, the Advanced system settings link is clicked among the links in the left pane.

Virtual Memory

3- In the System Properties window that opens, the Settings... button under Performance is clicked.

Virtual Memory

4- In the Performance Options window that opens, the Change... button in the Virtual memory section of the Advanced tab is clicked.

Virtual Memory

Step 2 - Turning Off Automatic Management

5- In the Virtual Memory window that opens, the Automatically manage paging file size for all drives option is selected by default. In this state, Windows manages which drive holds the pagefile and what size it is, and the options below appear disabled.

Virtual Memory

6- When the Automatically manage paging file size for all drives option is cleared, the System managed size option below becomes active.

Virtual Memory

At this point, 1 of 3 options can be set for each drive.

Option Result
Custom size The pagefile is kept on the selected drive between the entered Initial size and Maximum size values
System managed size The pagefile stays on the selected drive, and Windows determines its size according to the dump setting and the commit charge
No paging file No pagefile is kept on the selected drive. If no pagefile remains on any drive, the commit limit stays restricted to the physical RAM, and a memory dump cannot be taken if there is no dedicated dump file

7- When the Custom size option above the System managed size option is selected, the pagefile can be configured with user-defined values.

Virtual Memory

Step 3 - Entering the Initial Size and Maximum Size Values

The Initial size is the size of the pagefile that is reserved on disk in advance; the Maximum size is the ceiling up to which the file can grow when needed. The current commit limit depends on the size that is allocated to the pagefile at that moment. For this reason, raising the maximum size does not increase the commit limit on its own and does not reserve that much space on disk; it determines how far the file can grow when needed. With workloads that make frequent and large memory allocations, the growth of the file can be delayed, so it is safer to cover the expected need in advance with the initial size.

If the values you enter do not cover the part of the peak commit charge that exceeds the physical RAM, memory allocations can fail. If you use Complete memory dump, the pagefile on the system drive must be at least RAM + 257 MB.

8- The initial size and maximum size values are based on the total amount of RAM. For a total of 8192 MB (8 GB) of RAM, 12288 MB is entered as the Initial size value and 24576 MB as the Maximum size value, and the Set button is clicked to apply the assignment.

Virtual Memory

Virtual Memory

Checkpoint
After the Set button is clicked, the lower and upper limit values that were entered appear next to the relevant drive in the drive list at the top of the window.

9- The open windows are closed in order with the OK button. If you close the window without clicking the Set button, the values you entered are not saved. If the change requires a restart, Windows reports this with a message; in that case the new size takes effect after the computer is restarted.

If you receive warnings that virtual memory is running low, first check the commit charge and commit limit values in Task Manager and the free space on the drive that holds the pagefile. If the pagefile has reached its ceiling, you need to increase the maximum size value; if the file cannot grow fast enough to meet the need, you need to increase the initial size value.

Verification and Rollback

The applied configuration is verified through PowerShell. The command below returns the manually defined pagefile setting; the InitialSize and MaximumSize fields must show the values that were entered in MB, which are 12288 and 24576.

Get-CimInstance Win32_PageFileSetting | Select-Object Name, InitialSize, MaximumSize

To see the currently allocated size and the usage of the pagefile, the following command is run. AllocatedBaseSize gives the space allocated on disk for the file, CurrentUsage gives the amount in use at that moment, and PeakUsage gives the highest usage observed, all in MB.

Get-CimInstance Win32_PageFileUsage | Select-Object Name, AllocatedBaseSize, CurrentUsage, PeakUsage

The PeakUsage value is a good indicator of whether the size you set manually is too large or too small for the real need. If you want to roll back the configuration, it is enough to select the Automatically manage paging file size for all drives option again in the Virtual Memory window; the location and size of the pagefile are then managed by Windows again.

This article covered how the virtual memory mechanism in Windows and the pagefile, its counterpart on disk, work, why the pagefile is needed for the commit limit and for memory dumps, where it is stored and what determines its size. The initial size and maximum size values were then configured manually with the Custom size option, and the result was verified with PowerShell. On general-purpose systems it is enough to leave the size to Windows; if the size is configured manually, it is recommended to select the values according to the real commit charge measurement, the dump type that is needed and the requirements of the product that runs on the server.

I hope you find it useful...

No comments on this article yet. Be the first to comment!

750 characters available.
Security code
Comments are published once approved.
Your email is only used to let you know when your comment is approved. It is never published.