Page File – The definitive guide


Hello!

Today I will share with you my best practices for configuring the paging file in Windows Server 2008 and 2012.

Paging file seems to be a very popular subject, as we get questions about it all the time. Many customers are configuring the paging file incorrectly, based on outdated rules-of-thumb that are no longer apply to modern operating systems like Windows Server 2008 and above. 

Memory, Paging and Paging file

Let's start with the basics: Windows memory management is based on Virtual Memory, where each process has its own private virtual address space. Windows will move the least used memory pages to a hidden file called the page file, when approaching a low memory condition.

The Page file is a special file used by Windows to store modified pages, and the process of moving pages from RAM to the Page file is called "Paging".

Page files have two primary roles:

  • Physical extensions of RAM that store modified data
  • Record information about the state of the system in case of a system crashes

I will explain the size requirements for each role.

Physical extensions of RAM

If your server exhausted all available RAM and you don't have a page file, applications will crash or hang because Windows is unable to allocate more memory. Even worse, In some cases Windows itself can become unstable.

Windows Commit Limit, also known as system commit, is the sum of current paging files’ size and the physical memory that Windows can use to allocate memory. For example: If you have a 16 GB RAM and a 16 GB paging file, then your commit limit is 32 GB.

The Commit Limit can be increased by either changing the current paging files` size, adding new paging files or by adding more RAM. 

Crash dump size

On business-critical servers it's recommended to configure the server to capture memory dumps for analysis. Windows is using the paging file as a placeholder for memory dumps, meaning that Windows is writing the crash dump first in the page file, and then the SMSS process copies it to a different memory dump file. 

This have an effect on the page file size, because it needs to accommodate all the information Windows recording during a crash, more on this later.  

Sizing the paging file

The old rules of thumb (Page file size = RAM * 1.5 or RAM * 2) makes no sense in modern systems, where the logic should be: the more RAM you have, the less you need paging file.

So, how should you size your Page File?

Well, we don't have a magical value that will fit any system and any workload. It really depends on the specific workload and the type of server.

When sizing the page file we need to consider our applications memory needs and crash dump settings.

How do you know how much memory your application needs? The best way is to take a baseline.

  1. Run Performance Monitor (Perfmon)
  2. Go to Data Collector Sets\User Defined
  3. Right click on User Defined and select New
  4. Select Create Manually and next
  5. Check Performance counter
  6. Add the following counters:
      • Memory\Committed Bytes – Committed Bytes is the amount of committed virtual memory, in bytes.
      • Memory\Committed Limit – Amount of virtual memory that can be committed without having to extend the paging file
      • Memory\% Committed Bytes In Use – Ratio of Memory\Committed Bytes to the Memory\Commit Limit 


Note: Make sure you collect the information over a long period (one week at least), and the server is running at peak usage.

The page file size formula should be:

(Max value of Committed Bytes + additional 20% buffer to accommodate any workload bursts)-RAM size

For example: If the server has 24 GB RAM and the maximum of Committed Bytes is 26 GB, then the recommended page file will be: (26*1.2)-24)  = 7.2 GB

What about the second factor: the size we need to record information when the system crashes?


The size of the memory dump is determined by it's type:

  • Complete Memory Dump  RAM Size + 257 MB
  • Kernel Memory Dump  The amount of kernel-mode memory in use (on 32-bit maximum is 2 GB, on 64-bit the maximum can go up until 8 TB)
  • Small Memory Dump  64KB – 512 KB

In most cases the Kernel Memory Dump is good enough for root cause analysis, as Complete Memory Dump is only required in specific cases, for example you want to see what happened in the user mode.

From my experience, the size for Kernel Memory Dump is usually the following:

  • On System with up to 256GB RAM =  8-12 GB size for Kernel Memory dump
  • On System with up to 1.5TB RAM = 8-32 GB size for Kernel Memory dump

However, these numbers are NOT a Microsoft official recommendation, and may be different on your servers so always test before you apply.

Where to put the page file?

Starting from Windows 2008 and above you can place the page file on any partition, not just the system partition.

From the performance perspective you would benefit only if Windows is using the page file extensively (Commit Bytes is greater than the size of RAM).

Beside performance, disk snapshots and disk replication are also good reasons to move the page file to another partition on a different disk.

In this case you can consider moving the page file to another partition, just make sure the partition is running on a different physical disk (spindle), not on different partition on the same disk.  

Configuring the page file settings

You can configure the page file by using System Properties:

  1. Run sysdm.cpl
  2. Go to Advanced
  3. Select Settings under Performance
  4. Go to Advanced (again)
  5. Select Change under Virtual Memory

Let's explore the different options:


 

  • System managed – This is the default option and recommended by Microsoft
  • Custom Size – Allows you to manually configure the size of the paging file
  • No paging file – Configure the system for not having a page file

When using System Managed, Windows determines the size of the page file based on the amount of physical memory:

  • Less than 1 GB of RAM
    • The minimum size will be 1.5 * RAM, the maximum size will be 3 * RAM
  • 1 GB of RAM or more
    • The minimum size will be 1 * RAM, the maximum size will be 3 * RAM

On 32-bit systems the maximum size of the page file will be 4 GB, a relatively small size on modern systems. On 64-bit systems, for example an SQL server with 128 GB of RAM, the maximum page file size will be 384 GB. That doesn't mean that Windows will generate automatically  384 GB file, just if the system need this amount of Virtual Memory.

System Managed is the default option, and while it allows you to run the system without worrying about the size of the paging file in most situations, there are two potential issues:

  1. Disk Space – On systems with loads of RAM the page file size will be huge
  2. Page file Fragmentation – If the paging file expands and shrinks it can cause disk fragmentation and poor performance

This is the reason I usually recommend to manually configure the paging file on this kind of servers (High amount of RAM).

Starting from Windows 2012 there is a new behavior that designed to reduce the size of the paging file on systems with a large amount of RAM. When using System Managed and Automatic memory dump is enabled (by default) the maximum size will still be 3 * RAM, but the minimum size will be determined by several factors, such as size of RAM, committed memory history and free disk space, resulting in a much smaller paging file (less than 1 GB usually).


 
No paging file

As we discussed there is no need to disable the page file, even if your server has plenty of RAM.

There are two additional special cases regarding the need for page file:

  • Application requirements: Domain Controllers, DFS Replication, Certificate and ADAM/LDS Servers are not supported without a page file.
  • Guest VM with Dynamic Memory enabled (Hyper-V)Dynamic Memory requires that the VM will have a page file

 

As always voice your opinions and ideas in the comments

 

Comments (21)

  1. David says:

    Hi,

    Can you advise where the page file for a Kernal Memory Dump should exist if the OS page file is elsewhere? My impression is c: for the page file used for the dump when the OS page file is stored on another drive. Does 2012 / 2012 R2 Automatic memory dump change
    this at all?

    Thanks

  2. David says:

    Two more questions, for Domain Controllers (or Exchange) would you suggest setting an initial and maximum size for the page file if there’s a dedicated drive i.e. use up the space on the dedicate disk? I’ve read this can be performance intensive otherwise
    for it to calculate it on the fly.

    For Kernel Memory Dumps (2008 R2) should you configure a static size of at least 200MB if not 300MB? I ask as I understand 2012 / 2012 R2’s Automatic memory dump is able to change the size of the page file on the fly to accommodate the system chosen dump whereas
    this wasn’t a feature before.

    Thanks

  3. Moti Bani says:

    Hi David,
    1. Starting from Windows Server 2008 you can move the paging file to be on a different drive.
    2. Same minimum and maximum values are recommended for static paging file to avoid disk fragmentation
    3. Automatic memory dump will reconfigure (increase) the paging file after a bugcheck (Blue screen), and after 1 month without bugchecks it will be reduced automatically

  4. David says:

    Thanks Moti,

    1. So if I have the OS page file on another drive, how big should the c: page file be for a kernel memory dump? I gather around 200 – 300MB for 2008 R2?
    2. Thank you.
    3. If I select Automatic memory dump then do you select ‘system managed size’? Otherwise the page file configured in point 1. above won’t be big enough?

  5. Moti Bani says:

    Hi David, in every case the resultant Dump file can be sent to any drive with enough free space to contain it.
    You can have a small (100-200 MB) paging file on C: drive for best results

  6. Nebuly says:

    Hello,

    Do not forget moving the pagefile to another disk triggers issues – by example, deploying a new gold image with two partitions instead of one is more complicated, or having the pagefile on another LUN increases VM failure risks.

  7. David says:

    Just answering some of my own questions as I don’t completely agree with Moti Bani:

    http://blogs.msdn.com/b/chaun/archive/2014/07/09/recommendations-for-page-files-on-sharepoint-servers.aspx

    ‘However, if you completely remove the paging file from the boot partition, Windows cannot create a dump file (Memory.dmp)

    [One possible solution to consider] is to create one paging file that is, by default, stored on the boot partition, and then create one paging file on another, less frequently accessed partition.

    By design, Windows uses the paging file on the less frequently accessed partition over the paging file on the more heavily accessed boot partition. An internal algorithm is used to determine which paging file to use for virtual memory management.’

    And…

    http://blogs.technet.com/b/askperf/archive/2008/01/08/understanding-crash-dump-files.aspx

    ‘There is no way to predict the exact size of a kernel memory dump. When you configure kernel memory dumps the system checks to see if the page file is large enough. There are some guidelines for the minimum page file size needed for kernel memory dumps, however
    given that the size of kernel mode memory will vary, there is no accurate measure for the maximum. The default minimum page file sizes for kernel dumps are shown below:

    Physical RAM Minimum Page File Size (Kernel Dump)’
    < 128MB 50MB
    < 4GB 200MB
    < 8GB 400MB
    >= 8GB 800MB

    So I take from all this that…

    For both 2008 R2 and 2012 R2:
    – Move the page file to another disk and set the same minimum and maximum values

    For 2008 R2
    – Configure a 400MB or 800MB page file (dependant on table above), same minimum and maximum values, on C: for the Kernal Memory dump

    For 2012 R2
    – To allow ‘Automatic memory dump’ to create either a full memory dump or a Kernel memory dump, leave the size of the C: page file as ‘System managed size’ so it can increase and decrease as required.

    Cheers

  8. Moti Bani says:

    David,
    As stated in the link you provided these sizes are the "default minimum page file sizes ".
    From my field experience I can say for sure that these values are too small for many server roles: IIS, Exchange, File servers, Domain Controllers and many more are using a considerable amount of kernel memory.

    I agree that the best way is to check it, as the workload can vary in many different situations.

  9. David says:

    Moti,
    Agreed they are the minimum sizes, but in your above comment you actually suggested less!

    Moti Bani 1 Nov 2015 7:44 AM
    You can have a small (100-200 MB) paging file on C: drive for best results

    For a DC with 16GB RAM, what size pagefile would you expect a kernal memory dump to require?

    Cheers

  10. Moti Bani says:

    Yes, if you have a dedicated dump file to accommodate the memory dump requirements.
    If you don’t use dedicated dump file, size your paging file according to the dump type you want.

    It really depends what is the workload on the DC and the NTDS.DIT size.

  11. anonymouscommenter says:

    Pingback from Microsoft Windows Server – Ana Gauna

  12. HEMANT SINGH says:

    How to call startup and recovery window as shown in this article.

    1. Moti Bani says:

      Start -> “Run” and then type “sysdm.cpl”
      Goto “Advanced” and then “Startup and Recovery”

  13. Hi Moti,

    In case of System Managed, I would like to know what is the threshold value (is it 90%?) Windows 2012 will follow to increase the Page file size? Windows will increase the page file from current value, if the usage is above __ % of the page file?

    1. Moti Bani says:

      Hi Jitender,
      The paging file grows when system commit charge reaches 90 percent of the system commit limit.

  14. Chet says:

    What about the guest? If I have Windows server running as a guest which is only hosting a website, can I allocate 4GB RAM to the VM and disable the paging file of the guest OS?

  15. Pep says:

    Hi,
    On my Windows 2012 R2, I use to dedicate a separate disk for Pagefile, and remove it from “C:” drive. But when I select “system managed size” just for a single disk I’ll have a popup message that warns me that the disk size is to small to achieve the swap. And it avoids me use this option.
    But what is curious is that swap calculations done by windows are small than the required space to claimed by windows. And I could see that my real swap requirements are significanly less than windows wants to have

    How can I set “system managed size” for a single volume and bypass this warning? Using powershell commands, perhaps?

    Thanks.

  16. Jim says:

    Hi Monti

    Maybe my memory problem can’t be helped unless perhaps I create another partition on my internal hard drive?! Using an HP4530s business notebook/laptop with Windows 7 Professional 64-bit. Have the maximum 8GB of physical RAM installed.

    My pagefile.sys was put on HP_TOOLS by default by HP. Tried moving it to make larger, but that did not work.

    Then I read that minimum pagefile.sys should be (1xRAM = 8GB) in my case. Since I cannot put this page file on Local Disk (C:), the only other location that are NOT USB External hard drives (recommended not to put the pagefile.sys on any USB connections), The only other locations are HP_TOOLS (put there by default by HP), and HP_RECOVERY. Neither of these has the space (Thanks You HP!!!).

    Other than to sell more computers (thanks again HP, et al !!!), why would any manufacturer sell the capability to add maximum physical RAM, and not provide enough disk space on at least one internal hard drive partition to accommodate the minimum paging file?

    Maybe there are other options like tweaking the OS, and what HP does (they seem to stick a lot in my system I don’t need/want), but that’s another adventure.

    Anything other than written here on the right track to help 1) make a new partition on internal hard drive of at least 8GB just for pagefile.sys, 2) or closing apps, 3) or closing open tabs in CHROME {memory HOG – like it too much to switch browsers}, 4) or buy a new computer?

    Thanks – in a pinch – BJEvS

    1. Gary says:

      Hi,

      On 2003/2008R2 systems I would never set the pagefile so small (200Mb-300MB) and never set it to System Managed on servers.

      In the Virtual Memory settings (image above), the OS gives a Recommended and Currently Allocated value, you can use this as a guide to the custom settings. In the case above, I would set the Initial Size to the Recommended and the Maximum Size to 1.5 times the Recommended.

      (The Maximum Size, is the amount to which you can manually extend the pagefile without requiring a reboot)

  17. Lincoln says:

    One thing that was skipped in the article was the ‘Recommended’ listing in the ‘Total Paging File for all Drives’ box (in the example figure in the article, it’s 5616mb).

    How does Windows determine this number, and where can it be found in the registry or through WMI?

    Thanks!

  18. eng.Ismaiel says:

    Hi Moti,
    What about if the sum of (Max value of Committed Bytes + additional 20% buffer to accommodate any workload bursts) Less than physical Ram ,is this mean i dont need paging file ,in my case i used this formula to get the best number for paging file,i used windows server 2012 st,with 64 G Physical ram also the max committed Bytes is 47 G,
    Can you advice please

Skip to main content