Optimising Paging Files
What are paging files and scratch files?
Basically paging files are reserved space on your hard drive, designed to be used like an extension to physical RAM. The physical RAM and the paging file together are referred to as “Virtual Memory”. Paging files are hidden files that reside on the root folder of a partition (eg: c:\pagefile.sys)
Some programs that have high memory requirements (eg. Adobe Photoshop) will create an additional “paging file”, called a scratch file. The difference between paging files and scratch files is that scratch files only exist to serve the program they are used by, whereas paging files are used by Windows and installed programs that rely on Windows’ memory management system. Scratch files are often also temporary files that are only created as they need to be used. Paging files are permanent.
Page File Problems
There are a few problems associated with paging files. The first problem is that Windows will only allocate a maximum paging file size up to three times the size of of the available RAM. On systems with very little RAM, this means that a Windows managed paging file will be quite small. As an example, on a system with 512MB RAM, Windows will only allocate up to 1.5GB for the paging file. These days it’s easy to saturate 2GB of addressable memory space, usually bringing the system to a griding halt. Systems with 1GB RAM or more will be far better off. The maximum paging file size on 32-bit operating systems is 4GB. The maximum for 64-bit operating systems is 128TB (128,000GB)… Not that your PC needs that much extra memory space 😉
The second problem is that paging files significantly slower than physical memory. When a computer is forced to use virtual memory, the computer seems to lock up for a while as it process whatever operations it was doing. This is a typical symptom of not having enough physical RAM.
Another problem is fragmentation. Windows dynamically resizes the paging file based on the demand for memory. The problem with this is that the paging file can become fragmented on the hard drive, reducing overall system performance. There are a couple of ways around this, as discussed later in this article.
Optimal Page File Configuration
The best configuration is to have one page file on the Windows drive and another paging file on the first partition of each additional hard drive. Windows will use the paging file on the least active partition. The aim being to distributing the workload that hard drives need to do. Note the emphasis on “partition” rather than “drive“.
Paging files are dependent on hard drive speed. If additional hard drives are significantly slower than the Windows drive, then it’s possible that adding a paging file to those drive will deteriorate performance. Also, partitions that exist after the first partition on a hard drive are significantly slower than the first partition (sometimes up to 50% slower). Because of this, because of this, paging files should only be put on the first partition. With additional drives, a good idea is to make a dedicated partition for the paging file at the start of the hard drive. This guarantees that the paging file remains on the fastest part of that hard drive and also helps prevent page file fragmentation – provided that no other files are modified on that partition.
Many people misinterpret Microsoft’s advice and suggest that for better performance, the paging file should be moved from the C: drive to another drive. This is not true. One page file should be left on the C: drive and then extra ones are to be added to other hard drives. Windows relies on having a paging file on the C: drive to perform memory dumps. If your computer crashes, it tries to dump the data in RAM to the paging file and then generates a diagnostics report on the next reboot The memory dumps can be an invaluable tool for troubleshooting. As mentioned earlier, Windows defaults to the paging file on the partition with the least amount of activity. Chances are that additional partitions will be less active than the system (Windows) partition, so by leaving a paging file on the C: drive, there won’t be any adverse effect and it still offers the benefit of being able to perform memory dumps.
As mentioned earlier, page file performance can be degraded if they become fragmented. There are a couple of ways to avoid this. The most reliable way is to manually set the paging file’s maximum and minimum sizes to the same value. Instructions can be found in Step 2 of this article. Before doing this or before creating a paging file, the hard drives should be defragmented. If you’ve already fixed the pagefile size and it’s still fragmented, have a look at this guide (note the link for SysInternals PageDefrag).
—————————————————————————————————————————————————————————————-
The Microsoft articles for Page File Optimisation are KB314482 and KB197379. I hope you’ve fould this article useful!
Tags: memory, pagefile, performance, scratch, virtual