Defragging and sizing the Windows page file

Page Defrag is a great, free program for defragging the Windows page file and other system files.


An article from earlier today at about defragging the Windows paging file (Quick Fix: Put your paging file to work) needs some tweaking.

The article suggests that setting the page file Initial Size and Maximum Size to the same number will "avoid serious defragmentation". While this does avoid the paging file growing in size, the file can still be fragmented when it's initially allocated. So, if you're going to do this, you should defrag the hard disk first.

But, not allowing the page file to grow, is a questionable decision. If you make the page file too small, Windows may just stop - think of it like car without gas. If you make the page file too large, you are wasting part of the hard disk.

So, how big should your paging file be? The article says "The paging file should be set to at least 1.5 times the amount of RAM onboard." This is an old wives tale. It is a rule of thumb, not gospel.

The fact is, there is no way to know how large to make the page file. It is a function of the amount of ram available to Windows and the software being used. No single rule can ever be right for everyone. Thus, the page file is designed to grow, should the need arise.

Don't be misled by Task Manager in Windows XP. The Performance tab claims to show the page file usage, but it does not. The screen shot above shows a page file usage of 655MB. The page file on that computer was 300MB at the time.

In fact, the computer where this screen shot was taken, serves to illustrate how poor a rule of thumb can be. It was running Windows XP and had been used for three straight days without rebooting. It had 1.2 gigabytes of RAM. The initial page size was 300 megabytes and the maximum was 550MB. The page file never grows from the initial 300MB allocation. The rule of thumb would have allocated a page file of almost 2 gigabytes. But, of course, your mileage will vary.

So, how do you chose a size for the page file? As Chico Marx once said to Groucho - wrong every time.

That said, I would start by making the initial size the same as the amount of ram in the computer and the maximum size a bit larger. At the end of your computing day, check how big the file is (in Windows XP, the file name is pagefile.sys and, by default, it is in the root directory of the C disk). If it hasn't grown, you're fine. If it consistently grows, then make the initial size larger.

If, after a few days of checking, the page file has not once grown in size, then, for extra credit, you can lower the initial size, assuming you are willing to check it for growth all over again. Changing the initial size requires a reboot.

Page Defrag

But, how can you tell if the page file is fragmented? And if it is, what can you do about it?

Page Defrag is a great little program from Mark Russinovich, formerly of Sysinternals and now with Microsoft. The program is free, portable and from a trustworthy source. While initially designed just for the page file, the current version also defrags the registry, the event logs and the hibernation file. In other words, all the system files that normally can't be defragged.

When you run the program it reports the number of fragments for each of these files. In the best case scenario, shown above, they are all one. To defrag these system files, simply turn on the radio button for "Defragment at next boot". Since these files are always in use by Windows, they can only be defragged before Windows is fully up and running.

Note that according to the documentation, Windows Vista is not supported by Page Defrag.

See a summary of all my Defensive Computing postings.

Autoplay: ON Autoplay: OFF