Defragging The Windows Page File

Whenever you defrag your hard drive (using the tool which ships with Windows), you might notice there is a big green block which not movable. For the most part this green block is your Windows page file. Typically the way to make sure this gets defragged is to simply “delete it” by (steps abbreviated) removing the page file, defragging the hard drive and then re-setup the page file. Instead of this workaround, defrag the page file directly by using Sysinternals PageDefrag tool.

This free tool does just what you think, defrags your page file:

PageDefrag uses advanced techniques to provide you what commercial defragmenters cannot: the ability for you to see how fragmented your paging files and Registry hives are, and to defragment them. In addition, it defragments event log files and Windows 2000/XP hibernation files (where system memory is saved when you hibernate a laptop).

This tool is ideal to run on a fairly regular basis to prevent your virtual memory and registry information from becoming too jumbled.

Free eBook!

Like what you read?

If so, please join over 28,000 people who receive our exclusive weekly newsletter and computer tips, and get FREE COPIES of 5 eBooks we created, as our gift to you for subscribing. Just enter your name and email below:

Post A Comment Using Facebook

Discuss This Article (Without Facebook)

5 comments

  1. I’m an XP user and having had a taste of Vista I decided to stay with XP: Hence I don’t know whether or not the following programs’ functions are catered for by default in Vista, though I suspect not.

    Worth mentioning, with this in mind, are another two freeware programs; those being NTRegOpt and Erunt. http://www.larshederer.homepage.t-online.de/erunt/

    These two download in a single package: Erunt creates a backup of your system registry including open hives at startup and saves it to your a file in user account where it can be accessed from the command prompt in the Recovery Console.

    NTRegOpt optimises the open hives of yout NT registry that most defragmenters can’t get at by defragmaning and compacting.

    Another point worth mentioning is that if you use Diskeeper (2007 or 2008) there is a boot-time runonce defragmentation option available from the program’s GUI which also defragments your MFT in addition to paging file.

    Also in Diskeeeper is an option to pad out your MFT. (This is done manually with Diskeeper 2007 and automatically by Diskeeper 2008.) What this means is that when windows if first installed it creates a master file table with enough space for x many entries: This isn’t always large enough; and as the disk fills up it can cause the MFT to fragment causing system instability. Diskeeper resizes the MFT based upon an approximation of the expected number of files plus some, calculated by a complicated algorithm. This avoids MFT fragmentation as the disk fills up.

  2. Great post! I’ve been using Page Defrag since about a month after it came out and love it. It increases a slight amount to your systems boot time while it does the defrag but only around 10-15 seconds, pending your PC speed.
    It’s a great little tool and works great IMO

  3. Pagedefrag has a hardcoded error in it that shows its face if you tune your disks and filesystems for maximum performance by moving your eventlogs off of C: Drive. So, if you moved your registry hives or logs from their default area to gain performance, a hardcode that existed for pagefile.sys that APK fixed for Dr. Russinovich the author of this program, still exists in it, albeit for the registry hives and eventlogs of the operating system and applications.

    (Yes, this is doable, & e.g. -> via this registry path area + its variables of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application so you can move the application event log file to another disk to unburden the main C drive of that task)

    Thus, effectively helping to speed up its operations.

    Credits Alexander Peter Kowalski on that idea from Windows IT Pro magazine article where he helped Mark Russinovich out pointing out this fact to him and that his program also had the pagefile.sys location hardcoded as well, but, even though he alerted Dr. Russinovich of this at that article on Windows IT Pro magazine forums, I do not think it has been fixed for the registry hives or the eventlogs (although Dr. Russinovich fixed them for pagefile.sys at Mr. Kowalski’s suggestions and reguest, using the methods Mr. Kowalski suggested).

  4. Larry Miller /

    The problems caused by a fragmented pagefile have been greatly exagerated. Fragmentation impairs performance when a file is read or written serially. This NEVER happens with the pagefile. Pagefile IO is rarely more than 64K at a time and usually mixed with other paging activity. Yes, other paging activity, the large majority of paging does not use the pagefile. Pagefile fragmentation will not normally effect performance except in extreme cases. An extreme case would be hundreds of fragments.

    The initial portion of the pagefile will not become fragmented over time. Only when the system is forced to expand the pagefile will this occur. Windows will not do this without announcing this with a warning dialog. If you have not seen these warnings, the pagefile has not been expanded. In any event any pagefile expansion will be deleted on a reboot.

    The proper way to prevent pagefile expansion is to set the initial size so this need never occur. Trying to do this by lowering the maximum setting is totally wrong and will severly impair performance or cause application failures.

    If pagefile fragmentation is a problem then make sure the initial size is adequate and then use pagedefrag. Do this once and you will never have a fragmented pagefile again, even after months of heavy continuous use.

    Larry Miller
    Microsoft MCSA

  5. Be wary of actually deleting the page file before defragmenting old system disks.

    My experience (and that of others posting elsewhere) has been that this results in a page file that is has much worse fragmentation (e.g., > 1000 fragments, I saw one commenter say theirs had >26,000 fragments).

    I suspect that what is happening is that the disk defragmenter allocates all the large blocks to existing files, so when you allocate a new page file after defragmentation, the new page file just gets the leftover pieces.

    Three guesses on why there are only small pieces left over (may be a combination of all three):
    1. on old disks with many OS system packs and hotfixes, system files become spread all over the disk, and the disk defragmenter can’t move files that are in use, and so the spaces in between them are small.
    2. on old disks there may be sectors that have gone bad spread all over the disk. Can’t move those.
    3. disk defragmenter and PageDefrag just defragment existing files, not free space. (In fact they may keep free space fragmented on purpose, so there will be space nearby when any file is extended.)

    (I had hoped PageDefrag would move all the OS files [green slivers in disk defragmenter] together in larger blocks, but it doesn’t move them.)

    Instead of actually deleting the page file, stop using the paging file without actually deleting it, so disk defragmenter can try to defragment it.

Leave a Reply

PCMech Insider Cover Images - Subscribe To Get Your Copies!
Learn More
Every week, hundreds of tech enthusiasts, computer owners
and geeks read The Insider, the digital magazine of PCMech.

What’s Your Preference?

Daily Alerts

Each day we send out a quick email to thousands of PCMECH readers to notify them of new posts. This email is just a short, plain email with titles and links to our latest posts. You can unsubscribe from this service at any time.

You can subscribe to it by leaving your email address in the following field and confirming your subscription when you get an email asking you to do so.

Enter your email address for
Daily Updates:

Weekly Newsletter

Running for over 6 years, the PCMECH weekly newsletter helps you keep tabs on the world of tech. Each issue includes news bits, an article, an exclusive rant as well as a download of the week. This newsletter is subscribed to by over 28,000 readers (many who also subscribe to the other option) - come join the community!

To subscribe to this weekly newsletter simply add your email address to the following field and then follow the confirmation prompts. You will be able to unsubscribe at any time.

Enter your email address for
Free Weekly Newsletter: