Windows "Page File" Optimization

(the Page File is called the "Swap File" with Win95/98)

*** also see  PageFile Optimization  MS MVP Alex Nichol's XP Virtual Memory found HERE. Mike Lee's Blog HERE.

There are thousands of ways to optimize Windows.  Here we concentrate on disk, file, and memory management.

Hard Drive Optimization

few people know this - but use 4k clusters for the drive with the swap file !!!   And and 32k clusters for the other drive partitions.  The cluster size can be 4k, 8k, 16k, or 32k.  Many people use 32k since it means that the system will move and access big chunks of data.  That may work with Win95 and maybe even Win98.  However, Windows XP pages 4k at a time, regardless of the size of the clusters.  To do this using a page file that consists of 32k chunks, the system must buffer and break the 32k into 4k units - time consuming !!!  store So the best page file performance is obtained with 4K clusters — which is actually the normal size in NTFS and in FAT 32 partitions smaller than 8GB. This then matches the size of the page the processor uses in RAM to the size of the clusters, so that transfers may be made direct from file to RAM without any need for intermediate buffering

Memory - Physical and Virtual

Windows uses RAM (physical memory) as a high-speed depository for recent files and pieces of info that it needs.  But as you know, RAM runs out when you are running a lot of programs, and when that happens, Windows uses "Virtual Memory", which is a section of your hard drive that simulates real RAM - but it is drastically slower, of course.  The section of your hard drive reserved for RAM simulation is contained and accessed within a single file, called the "Page File".  Moving data in and out of the Page File is called "paging".  With older versions of Windows, the Page File was called the swap file, since moving data in and out was called "swapping"..

Since your hard drive is slow compared to RAM, the less paging the better.  One of the most effective things you can do to improve performance is ensure that there is enough RAM available to avoid frequent paging (swapping) of memory contents between disk and RAM.

Actual memory = physical + virtual memory = RAM + Pagefile

The Contents of RAM

Items in RAM can be divided into:

Any remaining RAM will be used to make the file cache larger.

Changing the Page File Settings:

  1. right-click on "My Computer" and select "Properties"
  2. click the :Advanced" tab and under Performance, click "Settings"
  3. click the "Advanced" tab
  4. in the Virtual Memory section at the bottom, click "Change"
  5. there you can select either "Custom Size" and enter the min and max number of Megabytes, or "System Managed Size" in which case Windows makes the determination for you (1.5 x RAM by default).  You can also select "No Page File" (but DO NOT do this - even if you have a ton of RAM).

NOTE:  if you have no "My Computer" icon, these steps allow you to select to display 4 icons - My Computer, My Documents, My Network Places, and IE on your Desktop

  1. Goto Control Panel/Display/ . . . 
  2. click the Desktop Tab
  3. click the "Customize Desktop" button
  4. check the icon/s that are missing

Page File Information

Recommended Size of the Page File - typically, the Windows default works fine, which is 1.5 x Ram.  But your system may need more or less, depending on how much RAM it is gobbling up.  The best way to find out - is to monitor the amount of RAM that is actually being used.  Here is a good, quick and easy utility to do that - Bill's Paging file MonitorSet it to write to a log file, and then periodically run it to add loggings (it cannot auto-run at intervals).  Especially, run it just before you shut down your programs, or before you log off or shut down since that is usually the time when you have the most demands on RAM.  Here is my own PageFileLog.txt where I ran the logger twice.  My peak usage is only 81 MB, and since I have 512 MB of RAM, I do not need to change the size of my swap file:

3/12/2006 10:00:10 AM
Pagefile Physical Location: D:\pagefile.sys
Current Pagefile Usage: 81 MB
Session Peak Usage: 81 MB
Current Pagefile Size: 768 MB

3/12/2006 9:46:57 AM
Pagefile Physical Location: D:\pagefile.sys
Current Pagefile Usage: 61 MB
Session Peak Usage: 61 MB
Current Pagefile Size: 768 MB

I have a ton of RAM, 512 MB - so why not select "No Page File" ??  Doing this would actually waste a lot of the RAM because many programs request a huge amount of reserved memory - even if they really do not need it.  For example, Photoshop may request 200 MB of memory and Premiere another 250 MB.  The system with a page file would allocate some of the to RAM and some to your Page File.  But with no page file it ALL would be allocated to RAM, and you would then be almost out of RAM.

Recreating the Page File - first off - NEVER DELETE THE PAGE FILE YOURSELF  !!!  People have done this on FAT32 partitions by using a Win98 boot disk.  But the system may not be able to boot up if you do that !!!  To delete and recreate the page file properly - go to virtual memory settinsg in Windows and select "no page file", reboot, and then select a page file to recreate one.

How much swap space do you need? That depends the amount of RAM you have and the programs you use. By default, WinXP sets your Page File to 1.5 times the amount of RAM you have. 

Fragmentation of the Page File - the size of the page file can change if you set it to "let Windows manage the page file".  When the page file is initially created, Windows looks for contiguous hard drive sectors to store it on, and marks them "unmovable", by the user.  But if you let Windows manage the page file - and the load increases, the size of the page file will be increased, and the exra space may be placed on a different area of your hard drive - i.e. fragmentation occurs !!

A Common MYTH - it is best to keep the Page File from changing size - DO NOT DO THIS !!  but f you must, use custom settings and set the min = max.  It is best to use the recommended 1.5 x RAM for the size.
OK, why not do it??    of course, you do want to minimize changing the page file size, because it can fragment if made larger - although it there is contiguous space next to it, then it will NOT fragment and can grow.  So set the initial size large enough to handle the normal needs of your system.  But no restriction should be placed on its further growth.  It needs to be able to grow, whenever your system needs more than the min setting !!  This provides for contingencies, like unexpectedly opening a very large file, in XP this potential file space can be used as a place to assign those virtual memory pages that programs have asked for, but never brought into use. Until they get used — probably never — the file need not come into being. There is no downside in having potential space available.

Can I move the Swap file to the Outer portion of my drive ?? - the outer portion of your drive is MUCH FASTER than the inner portion.  Norton could move the swap file to that area of the drive with Win98 by running the Optimization Wizard and rebooting, and then Speed Disk would auto-start.  But not with WinXP, since the page file cannot be changed while in Windows.

PageFile De-Fragmentation

and (less important)  .  .   Hives de-fragmentation

The "Page File" is WinXP's version of the Win98 "swap file".  But it is more complex, and is locked - and cannot be de-fragmented while in Windows.  Norton Utilities can only defragment Win98 swap files.  Then SysInternal came to the rescure with an amazing and free utility.  When you run it, it displays the number of fragments for your Page File, and for each of your Hives, and the "Hibernation file" if you are sing a laptop.  Here is a sample screenshot:


If the Pagefile (c:\pagefile.sys - a hidden file) gets fragmented your system's performance will decrease. System Internals has released PageDefrag, a free utility that shows fragmentation in the Pagefile and then offers the option of defragmentation at boot time.

The utility can be downloaded from HERE

Once you download just unzip the file and run pagedfrg.exe.