Swap file fragmentation: fact or fiction?

This is about Windows, but I'm sure it applies to other OS as well.

I've heard people say that if you want better performance, you should avoid swap file fragmentation. To do this, you can either manually specify a constant size for the swap file, or even move it to a dedicated partition/disk.

Will this really give any performance benefits? After all - the swap file is accessed in a randomized manner anyway, what's a bit more randomization? And if you're considering a separate disk for the swap file, then you would be far better off investing your money in more RAM instead. Unless you happen to get a free disk of course.

So - is there a point in fighting swap file fragmentation or not?


Pagefile fragmentation will only be a significant factor in extreme cases. Fragmentation is a factor when large files are read serially, but this almost never happens with the pagefile. Pagefile access is in small blocks of no more than 64K, and this will be usually mixed with access to other files. It matters little if the pagefile is fragmented or not, the disk heads will be moving around in any case.

None of this really matters unless pagefile performance is a limiting factor. And it usually isn't. Most paging doesn't use the pagefile at all. By design the pagefile is used to store data that is not accessed frequently. In most cases the pagefile isn't accessed often enough for it's performance to matter.

In most cases this is just much adu about nothing. The misquided attempts to solve the problem can, and often do, cause serious problems.


This certainly isn't an issue on Linux systems where swap is always a partition with a special file system for swap files. It's obviously a possible issue on Windows, and I think it's a possible issue on Mac OS X too since it seems to use files for swap.

TBH, I don't have any hard-facts to back up my view, but, I have anecdotal evidence that suggest it's better to have your swap not changing size because a change in swap size seems to really slow windows down while it's happening. The size of a disk you'll want for swap will always be smaller than what's currently considered an average disk, so, old disk will generally be more than big enough for swap. So, it's possibly a good use for an older disk when you upgrade to the latest 1TB disk.

When I ran Windows machines, I always either created a swap partition or used a separate disk, and then told Windows to use only that disk for swap, and set it not to change size. I would set it to use 2.5 times the amount of RAM as both the min and the max and leave it at that. I have no way of knowing for sure whether it really helped, but it certainly didn't have any negative side effects.