Posted on Mar 2, 2006

On page file defragmentation

My laptop was spending a lot of time reading its hard-disk while switching between tasks or invoking a new task. I suspected file fragmentation being the cause and ran the Windows Disk defragmenter tool. Some big movie files were heavily fragmented as I copied them over when free space was running low (29000 fragments for one 600MB file!) but all the commonly used files were in tact. Then I noticed the pagefile (pagefile.sys) – it was showing heavy fragmentation, but the Windows Disk defragmenter cannot defrag pagefiles.

That is where Pagedefrag helps. It runs at boot time and can defragment the page file, registry and hibernation file (where the memory snapshot is stored when computer is hibernated). I ran Pagedefrag and it reduced my pagefile from 6900 fragments (!) to 84 – some improvement!. And the performance of my laptop has improved considerably.

Anyways, prevention is better than cure, and there is a way to prevent page file fragmentation from happening. Create a separate partition and use it to store the pagefile similar to the Unix swap space. There would be some performance improvement too if this partition is on a separate hard disk which does not contain frequently accessed files.

There is some good information on improving paging performance at:

http://www.windowsdevcenter.com/pub/a/windows/2004/04/27/pagefile.html