Windows 7 / Getting Started

Part 2: Defragment the paging file

The steps in the previous section eliminate the possibility of your swap file becoming fragmented, but they won't cure an already fragmented one. You'll need to defragment your virtual memory for the best performance, but the good news is that you need to do it only once if you have a constant-size paging file.

There are several ways to defragment your swap file:

Use PerfectDisk
Use an advanced defragmenter like PerfectDisk, discussed in "A Defragmentation Crash Course" earlier in this tutorial. Just instruct it to defragment your system files, and it will schedule a defragmentation for the next time you start Windows.

Use another drive temporarily
If you have more than one partition or hard disk in your system, start by moving your swap file to a different drive letter, as described in the previous section. Then, open a Command Prompt window (cmd.exe) and type:
defrag c: /x
to defragment the free space on the drive. See "A Defragmentation Crash Course" earlier in this tutorial, for more on this tool.
When it's done, move the swap file to its new home, where it will rest nicely in the newly-allocated contiguous block of free space.

Turn off virtual memory temporarily
If you don't have a second drive, your other choice is to disable virtual memory altogether by clicking No paging file and then Set in the Virtual Memory window. After restarting Windows, run Disk Defragmenter as described above to set aside a large chunk of contiguous free space. When you're done, go back to the Virtual Memory window, and re-enable the paging file, making sure to set a constant size.

Clear the paging file automatically
See "Part 3: Clear the paging file on shutdown", next, for another way to reduce fragmentation in your paging file.
[Previous] [Contents] [Next]