Captain Debugger

Windows Advance Troubleshooting Technique

  • Author

  • Microsoft MVP

  • Cloud

  • Subscribe

How to Size Page File

Posted by Shyam Sasindran, MVP on February 10, 2011

What is Page File:

In storage, a pagefile is a reserved portion of a hard disk that is used as an extension of random access memory (RAM) for data in RAM that hasn’t been used recently. A pagefile can be read from the hard disk as one contiguous chunk of data and thus faster than re-reading data from many different original locations.

RAM is a limited resource, whereas virtual memory is, for most practical purposes, unlimited. There can be many processes, each one having its own 2 GB of private virtual address space. When the memory that is in use by all the existing processes exceeds the amount of available RAM, the operating system moves pages (4 KB pieces) of one or more virtual address spaces to the hard disk, thus freeing that RAM frame for other uses. In Windows systems, these “paged out” pages are stored in one or more files that are named pagefile.sys in the root of a partition. There can be one such file in each disk partition

Note: To understand this post better we need Process Explorer by SysInternals

Address Space Limits
  • One virtual memory limit is address space
  • Another is the system commit limit

The address space for 32-Bit Computers are

32-bits = 2^32 = 4 GB

Where by default 2GB is User Process space and 2GB is System Space. With boot.ini: /3GB or /USERVA the User Process space can be 3GB and 1GB of System space. So 32-Bit can run out of the address space. Only way to increase the address space to upgrade to 64-Bit

The address space for 32-Bit Computers are

64-bits = 2^64 = 17,179,869,184 GB

The Windows architecture can support much more, but as of now, the largest system Microsoft has tested is 2 TB (Itanium):

Windows only assigns space in the pagefile when a virtual memory page must be paged out.  Thus the total available virtual memory is approximately the sum of installed RAM and the size of the pagefile

There are lot of arguments on How big the Pagefile size should be some used to claim it’s the 1.5X of the RAM etc. A computer can run without Pagefile but it’s not recommended because when your System crashes and it has to write a Kernel dump it save that to the Pagefile and there is not way to measure that because it depends up on the depth of failure, number of Programs running etc.

If the minimum and maximum pagefile sizes are not the same, the pagefile will initially be allocated to the minimum size, then expanded as more space is needed, up to the maximum.    

image

    Task Manager Value

    Definition

    Memory bar histogram Physical

    Memory usable by Windows (not available as a performance counter; represents RAM usable by the operating system, and does not include BIOS shadow pages, device memory, and so on). Measured in available bytes.

    Physical Memory (MB):

    Total Physical memory usable by Windows

    Physical Memory (MB): Cached

    Cache bytes + modified page list bytes + standby cache core bytes + standby cache normal priority bytes + standby cache reserve bytes

    Physical Memory (MB): Free

    Free and zero page list bytes

    Kernel Memory (MB):

    Total Pool paged bytes + pool nonpaged bytes

    Kernel Memory (MB): Paged

    Pool paged bytes

    Kernel Memory (MB): Nonpaged

    Pool nonpaged bytes

    System: Page File (two numbers shown)

    Committed bytes / commit limit

    Virtual Memory Types

    Process Committed: contents are backed by a file on disk (data file, image or paging file)
    Address space breakdown

    Committed:

    • Shareable (e.g. EXE, DLL, shared memory, other memory mapped files)
    • Private (e.g. process heap)

      Uncommitted:

    • Reserved (not yet committed)
    • Free (not yet defined)

      Pages in a process virtual address space are free, reserved, or committed. Applications can
      first reserve address space and then commit pages in that address space. Or they can reserve
      and commit in the same function call.

      Reserved address space is simply a way for a thread to reserve a range of virtual addresses
      for future use. Attempting to access reserved memory results in an access violation because
      the page isn’t mapped to any storage that can resolve the reference.
      Committed pages are pages that, when accessed, ultimately translate to valid pages in physical memory. Committed pages are either private and not shareable or mapped to a view of a section (which might or might not be mapped by other processes). Sections are described in two upcoming sections, “Shared Memory and Mapped Files” and “Section Objects.”
      If the pages are private to the process and have never been accessed before, they are created at the time of first access as zero-initialized pages (or demand zero). Private committed pages can later be automatically written to the paging file by the operating system if memory demands dictate. Committed pages that are private are inaccessible to any other process unless they’re accessed using cross-process memory functions.

      If committed pages are mapped to a portion of a mapped file, they might need to be brought in from disk when accessed unless they’ve already been read earlier, either by the process accessing the page or by another process that had the same file mapped and had previously accessed the page, or if they’ve been prefetched by the system.

      A frequently asked question is “How big should I make the Pagefile”? 

      There is no single answer to this question, because it depends on the workload on the computer, how much RAM there is and how much virtual memory space that workload requires. 

      Actually, the more RAM, the smaller the paging file needed. So how does the system size the paging file with the default System Managed?
                                                                                                                                                Minimum: 1.5x RAM if RAM < 1 GB; RAM otherwise
      Maximum: 3x RAM or 4 GB, whichever is larger

      So to Size the Page File you can check the Commit Charge Limit

      image

      What ever the the Peak size and percentage of limit we know how much Page File we need. 

      To get to this screen Open your Process Explorer and press Ctrl + I

      How to set Page File

      Go to Start and Right Click on Computer and Click on Properties

      image

      Then Click on Advance System settings and Click on Advance Tab then Click on Settings

      image

      The Click on Settings

      image

      Then Click on Change

      image

      Here you can select the Custom size and Enter the Page File size according to your Workload or Commit Limit.

      Do You Have Enough Memory?

      “Do I have enough RAM ?” Another question which most of them ask. There’s no sure-fire rule or counter to tell if you if you have enough memory. According to Mark Russinovich’s recent seminar and his book he has mentioned

      The general rule: available memory remains generally low

      • Use Perfmon to monitor available memory over time
      • Use Process Explorer, or on Vista and later Task Manager, to monitor physical memory usage
      • Use Process Explorer or Task Manager to see instantaneous value
      • Watch in Process Monitor for excessive reads from paging file

      image

      Most of contents of this post has been taken from recent seminars of Mark Russinovich and few article on web and Windows Internals.

      Leave a comment