Page file size

Tue, 2007-07-17 13:11 by admin · Forum/category:

What's a page file?

Modern processors support virtual memory. The software gets a relatively large RAM (Random Access Memory, solid state memory chips, as opposed to a hard disk) address space, not all of which needs to be physically present in RAM. If a program tries to access memory that happens to be swapped out, i.e. not currently present in RAM, it is interrupted and the missing memory page loaded from the hard disk, while the computer can do something else. If the RAM was full, another page has to be swapped out first. This process is transparent to the software, which experiences only a delay, but doesn't otherwise have to do anything special to access virtual memory.

If the working set, i.e. those memory pages that are frequently used, is smaller than RAM, the computer will run at a good speed with occasional swapping, even though the total address space of all running programs is much larger. If, however, the working set is too large, you will experience "thrashing", i.e. rapid, frequent or continuous swapping, and the computer will slow down to a crawl, waiting for memory pages most of the time. Your options are:

a) Use fewer programs or programs with lesser memory requirements.
b) Add more RAM.

At the generally low and sinking RAM prices the latter option is recommended.

In Windows the place on the hard disk where swapped RAM is stored is a file called page file or swap file. The file name is: pagefile.sys

How big should my swap file be?

There are some simple rule of thumb recommendations, but they are not very useful, because the best size of the swap file depends on your particular usage. It has not much to do with RAM size. Those rules of thumb are often beside the point.

The only simple rule of thumb that I would subscribe to is this. If you have no idea of future usage and no severe shortage of hard disk space, simply set the swap file to 2 GB, both min and max.

If you plan to record full memory dumps in case of blue screen errors, the page file needs to be at least a bit (12 MB, to be precise) bigger than the RAM. If you don't know much about memory dumps, set the system to record only minidumps. And if you plan to use fast user switching, you need a bigger page file.

The better, but still simple way to determine what you need is to observe actual usage. For example, press Ctrl + Shift + Esc and watch the figures.

Set the minimum size somewhat larger than what you observe at maximum usage. It is good to set the minimum relatively high, because a growing swap file may get fragmented. Therefore it is better to make sure that you can work without a swap file enlargement most of the time.

Another reason is that a sudden large demand at virtual memory by some running program often triggers the warning message "low on virtual memory" before Windows automatically increases the swap file size.

The maximum size can then be increased further, to your liking. It acts as a worst case extension of the swap file. If you ever get severe problems due to lack of virtual memory, enlarge your maximum swap file setting. However, if disk space is not at a premium or if the machine is a server and runs nonstop for longer times, it is better to raise both min and max settings and keep them equal.

If you never get that warning message, you could try decreasing your swap file size until you get it.

If you have two hard disks, then the swap file should be on the disk that is least often used, often the one on which Windows is not installed. With more hard disks you can have several swap files.

If you want more background information, please read the following excellent article by fellow MVP Alex Nichol:

Virtual Memory in Windows XP

Please see also the Microsoft Knowledge Base article:

Configuring Page Files for Optimization and Recovery