As a trainer and consultant in the computer field, I see over 10,000 clients a year. I have yet to go through a week without hearing questions about the ideal settings for the swap file, also known as the pagefile in Windows 2000. Settings for swap files remain one of the most misunderstood features of Windows operating systems. Anyone who has ever looked into optimizing a computer using Windows 2000/NT or Windows 95/98 has come across numerous conflicting suggestions. In this Daily Drill Down, my goal is to lift the veil of confusion on the swap file. I’ll also explain the configurations that work best for me.

What is the swap file?
As you probably know, Windows is a multitasking operating system, meaning it can run more than one application at the same time. To help accomplish this feat of magic, if Windows has too much data to fit in physical memory (RAM), some of the information is stored in a file on the hard drive. Typically, this file resides in the boot partition—most often the C: drive. The file in which this data is stored is referred to as virtual memory, a swap file, or a pagefile. In Windows 9x, the file is called Win386.swp. In Windows NT and 2000, the file is called Pagefile.sys.

Page faults and invalid page faults
The information not immediately needed in physical memory is saved through a process known as paging. A page is made up of 4 KB of data. When a program needs a page of information that resides on the hard drive, Windows copies the page back from the swap file to the main memory.

To understand the paging process, you need to be familiar with the term page fault. A page fault is not really a fault at all—it simply refers to the fact that information needed by an application is not currently in memory but is on the swap file or pagefile. When a page fault occurs, the Virtual Memory Manager swaps the page off the hard drive back into RAM and the contents of that 4-KB RAM address to the hard drive. An invalid page fault error occurs when the area in RAM to be swapped is being used by an application or the block of memory does not exist. The result is usually an aborted program operation.

Dynamic paging
In Windows 2000/NT and Windows 95/98, swap files can shrink and grow based on need; in other words, the process is dynamic. Although this may sound efficient, dynamic paging causes a number of problems. On systems with large hard drives, the continuous growing and shrinking of the swap file results in increased fragmentation of the hard drive, which leads to increased reads and writes. This, in turn, leads to slower access and unnecessary wear. The result is slower program execution in light of increased CPU activity.

A classic symptom I hear about often is Windows locking up for a minute or so because of the random disk activity. If you see the hard drive light coming on regularly, accompanied by slow program performance, this could indicate problems with paging. For these reasons, setting a fixed-sized swap file is a good idea.

Don’t forget memory
Buying more RAM can solve many paging issues. The more physical memory, the better your chances that programs will run in memory, reducing swapping and increasing system performance. Due to the I/O speeds of RAM versus hard disks, swapping will always be slower. But how much RAM do you need? The simple rule of thumb is you can’t have too much RAM.

Although the minimum requirements for Windows 98 are 8 MB, realistically, you need a minimum of 32 to 48 MB. Windows NT 4.0 Workstation has a minimum requirement of 16 MB of RAM. I recommend a minimum of 32 to 64 MB. Windows 2000 Professional’s recommended minimum RAM is 64 MB. As with the other OSs, you’ll want more. I recommend 128 MB as a minimum. Windows NT can support up to 4 GB of RAM and 2 GB of virtual memory. Windows 2000 can support up to 4 GB of RAM and 4 GB of virtual memory. The 4-GB pagefile limit can be exceeded by creating multiple pagefiles (if for some reason you need such a large amount of paging).

In addition, ensure that you have adequate free disk space on your hard disk drive. Large hard drives are available at a reasonable cost per megabyte of storage. Software requires increasing storage space and memory to both load and run. My experience shows that most power users currently should invest in at least a minimum of a 6-GB drive.

Myth: Microsoft knows best
According to Microsoft, allowing the Windows 9x swap file to run dynamically is usually the most efficient use of resources. Unlike in Windows 3.x, the swap file in Windows 9x can also exist on a compressed or fragmented drive with no substantial performance penalty. Microsoft does say that you can adjust the parameters if you wish; however, it offers no algorithm for selecting the appropriate numbers. By default, the minimum is 0 and the maximum is the total free space available on the drive.

I disagree with Microsoft’s general statement because anyone who has used a badly fragmented drive or a compressed drive is well aware of the performance hit entailed. Given the low price of hard drives these days, this should be a moot point.

Option 1: A fixed pagefile
You should place the swap file on a separate drive or partition if possible. But if you have only one drive and are unable to partition it, I recommend the following steps:

  1. Multiply your physical memory by 2.5.
  2. Choose either the number from the calculation in Step 1 or 256 MB, whichever is less.
  3. Right-click My Computer, select Properties, select the System Performance tab, and click the Virtual Memory button.
  4. Select the Let Me Specify My Own Virtual Memory Settings option.
  5. Set both the Minimum and Maximum swap file size to the number you used in Step 2.
  6. Click OK and then restart the computer when prompted.

Option 2: Dynamic swapping on a separate drive or partition
If you can place the swap file on a separate drive or partition, don’t use that drive for saving other files. This way, there won’t be any competition for disk reads and writes. I recommend a partition of no more than 2 GB—that space should be adequate for any Windows 95/98 swap file. If the swap file is on a separate drive, you can let Windows manage the swap file dynamically because there will be no I/O conflict with other programs or files.

In either case, be sure to follow the steps outlined below in “Setting up your swap file” before changing any of these options. I also recommend that you back up the registry, as you should do every time before making a major change to the system.

TechProGuild contributor Jeff Davis covers a feature used by Windows 98 to improve memory utilization and performance (see “A primer on swap files”). I will not repeat Jeff’s fine overview of this service, which is called Page_File_Async_Manager. However, from my personal experience using a Windows 98 SE, PIII 550-based machine with 128 MB of RAM and a 25-plus-GB hard drive, this new feature offers little noticeable improvement unless you regularly run heavyweight applications such as Microsoft Access, PageMaker, AutoCad, or similar products. I have found that limiting the maximum swap file size to 256 MB and disabling this feature results in a performance advantage for the majority of everyday tasks. See Jeff’s article for information on how to disable this service.

What’s the best swap file size for Windows NT 4.0 Workstation?
Unlike with Windows 95/98, Microsoft provided a recommendation for the size of your pagefile in Windows NT. The algorithm recommended was:
Pagefile = RAM + 12 MB

For more information on this algorithm, read Ivan Mayes’ overview of the Windows NT paging file, “Configuring and managing virtual memory paging files.” I’d like to clarify how best to apply the algorithm used to calculate the minimum and maximum pagefile sizes.

Although Windows NT requires a minimum 2-MB paging file, sometimes this will prove inadequate and is valid only for systems with at least 32 MB of RAM. For less powerful machines, of which I still see a number every year, use a different calculation. For a machine running with 16 MB of RAM, the minimum should be 16 MB and the maximum 28 MB, following the Microsoft recommendations. For a 32-MB machine, use a minimum of 8 MB and a maximum of 48 MB, again, following the same algorithm.

Another rule of thumb used by many administrators is what I call the 12/50 rule: In the minimum setting, use the calculated minimum RAM plus 12 MB; in the maximum setting, use the recommended minimum plus 50 MB.

Works for me
While these various algorithms may have sufficed at the time, programs have grown in size and complexity. At the same time, hard disk space has come down in price. In addition, it’s difficult to arrive at a number that works in every circumstance. After much experimenting with Windows NT 4.0, I’ve found the following configuration to work best for a server or workstation:
Minimum Pagefile = RAM + 100 MB
Maximum Pagefile = Minimum + 20 percent

Again, as with Windows 95/98, you can make both the initial pagefile size and maximum pagefile size the same value, ensuring that the operating system has enough swap file space and eliminating unnecessary fragmentation of the swap file as it grows. The advantages of placing your swap file on a different drive or different partition are the same as those given for Windows 95/98. With Windows NT, the pagefile can span multiple drives. Be sure that you use multiple physical drives, not multiple logical drives on the same partition if you choose this option.

One last tip regarding the Windows NT paging file: Microsoft recommends you use the NTFS file system. However, unless security is an issue, if the drive or partition is no more than 2 GB in size, use FAT instead. It is a known fact that FAT is, as a general rule, faster than NTFS on smaller drives/volumes.

What’s the best swap file size for Windows 2000 Pro?
Windows 2000 Pro is quite similar to Windows NT. Both operating systems require a minimum 2-MB pagefile on the boot volume for system use, such as process error reporting. Because Windows 2000 Pro is built on the NT Kernel, any additional RAM will improve performance; Windows 2000 Pro requires more than the Microsoft recommendation of 64 MB of RAM to help minimize paging.

The Windows 2000 Pro setup process will default the pagefile size to installed RAM plus 12 MB. Keeping in mind the fact that Microsoft designed Windows 2000 for nonstop operation, adequate pagefile size is critical. The Microsoft default will suffice for most general use; however, setting both the minimum and maximum at the same value will offer performance efficiencies, as with NT. These efficiencies include less overall fragmentation and concurrent reduction in disk activity as Windows 2000 will not have to constantly look for more virtual memory space as required.

A new feature in Windows 2000 Pro is a dialog box informing you when the Windows virtual memory minimum is too low. Ironically, it suggests that you use the online help to resolve the problem, assuming you have enough memory left to access it!

I recommend you follow the basic algorithms as used for NT. The minimum should never be less than the installed memory. To ensure this requirement is met, use the following configuration:
Minimum Pagefile = RAM + 100 MB
Maximum Pagefile = Minimum + 20 percent
It is more critical with Windows 2000 Pro that you adjust the pagefile size whenever a memory upgrade takes place.
As with NT, avoid placing the pagefile on a fault-tolerant drive and try to put the majority of the pagefile on a drive separate from the boot volume with the operating system. Remember to leave the minimum of 2 MB on the boot partition. To monitor your success in assigning your pagefile, utilize the Process(_Total)\Page File Bytes counter in the Performance Monitor.

Setting up your swap file (Windows 9x)
One of the most important steps needed to ensure the efficiency of your operating system and maximum use of the associated swap file is defragmentation. This should be done when initially setting up your hard drive. (Note: This step will not be necessary when using third-party defragmentation utilities, such as Norton’s Speed Disk or a similar product.) When using the default defragger found in Windows 95/98, the process requires manual procedures.

To defrag your hard drive manually in Windows 95/98:

  1. Right-click My Computer, select Properties, and select the System Performance tab.
  2. Click the Virtual Memory button.
  3. Select the Let Me Specify My Own Virtual Memory Settings option.
  4. Set both the Minimum and Maximum swap file size to 0. Click OK and answer Yes to the computer restart message.
  5. Once the computer has restarted, run the disk defragmenter on the C: drive.
  6. Double-click My Computer.
  7. Right-click your drive’s icon and select Properties.
  8. Click the Tools tab.
  9. Select the Defragment Now option and let the program run to completion.

As you probably know, you should disable your screen savers and virus scan utilities before you run either the Scandisk or Defrag program. Once the defrag process is completed, go back to the Virtual Memory dialog box. Set the minimum and maximum swap file size to the settings discussed earlier. You must reboot to ensure that Windows stores your changes correctly in the appropriate registry key.

Setting up your Pagefile (Windows NT)
Creating an unfragmented pagefile in Windows NT 4.0 requires one of the following:

  • You have a freshly formatted partition.
  • You run a defragmentation program (such as Executive Software’s Diskeeper).

To create a new pagefile in Windows NT 4.0:

  1. Go to Start | Settings | Control Panel | System.
  2. Select the Performance tab and click the Change button.
  3. Select the new partition for the pagefile.
  4. In the appropriate dialog box, set the minimum and maximum pagefile size(s) as described earlier and click Set.
  5. Select the current pagefile, set both minimum and maximum to 0, and click Set.
  6. Restart the system.

These steps will ensure that you have a contiguous, fully unfragmented pagefile. As with Windows 9x, avoid saving any files on this partition.

Setting up your pagefile (Windows 2000 Pro)
Windows 2000 Pro includes Dfrgntfs.exe, a limited version of Executive Software’s Diskeeper disk defragmenter. To access this tool, choose Start | Programs | Accessories | System Tools | Disk Defragmenter. Note: You cannot run Dfrgntfs.exe from the command prompt.

Although you cannot defrag a pagefile while it is in use, you can temporarily assign it to a different drive (volume). To accomplish this, follow these steps:

  1. Defrag the drive that contains the current pagefile.
  2. Create the new pagefile on the other drive.
  3. Set the current file’s pagefile size to 0 to delete it. Reboot.
  4. Recreate the original pagefile.
  5. Set the temporary pagefile size to 0 to delete it. Reboot.

These steps will ensure that the recreated pagefile consists of contiguous, unfragmented disk space.

The bottom line
You’ve no doubt encountered a number of opinions about the best ways to set your Windows swap files and pagefiles. In this Daily Drill Down, I’ve presented my personal choices, based on my many years in the industry and training. If the e-mail I receive is any indication, the debate will continue.
The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.