Updated 20 minutes ago

How to optimise your Windows swap file

In Depth: Take optimising to the extreme - we benchmark the options

September 20th 2009 | Tell us what you think [ 6 comments ]

pagefile-swapping

Access to the page file gets pretty hectic once memory starts getting tight

It's one of those questions that raises its ugly head a couple of times a year, everyone makes some type of grunting noise, no real conclusion is reached and it's forgotten about until the next bemused victim asks all over again.

That question was about the Windows swap file, aka the page file, aka virtual memory. Over the years we've heard all the so-called best methods; no swap file, fixed swap file, system managed file, on the main partition, on its own partition, twice the system memory, three times the system memory, fragmented, defragmented...

A huge reason for all of this is the historical way Microsoft has tackled the subject and implemented virtual memory within Windows. The fact so many people call it the wrong thing is testament in itself to how badly understood the subject is, particularly when you consider virtual memory has been implemented in Windows since version 3.0 and has been around far longer than that generally in the computing world.

So we decided it was about time we took a comprehensive look at all the different scenarios and see which, if any, is actually optimal. Along the way we'll learn a lot and as we'll see come up with some pretty novel solutions that are immensely helpful beyond just the single goal of getting an optimised page file.

So no matter if you think you know it all or if you've never even heard of a page file before, we think you're going to learn something new along the way. From how best to set-up your page file, how to avoid the usual pitfalls, to some intriguing tricks that are just damn handy to know about.

What do people mean by swap file?

When someone mentions swap file or page file to you what are they talking about? Well, technically Windows 9x has a WIN386 swap file, while Windows NT/2000/XP/Vista/7 use a PAGEFILE file.

You can see why the two phrases are used interchangeably. However, the confusion doesn't stop there. All of this is connected to the Windows virtual memory system, which is what we're really talking about here.

Virtual memory enables an OS to virtualise the physical memory space to another storage medium, usually a hard drive. To do this both the kernel of an OS and the processor it's running on need to support the function.

Over 20 years ago that might have been an issue, but not today. The whole point is that when an app requests a block of memory it may see itself being given a block of real memory. In reality only part, or none at all, of this could be 'real' with the rest stored temporarily virtualised on the hard drive.

If an app requests memory that's stored off in this virtual world, a 'page fault' is generated, the virtual memory is swapped over to real memory in chunks called 'pages' and everything carries on.

The primary reason why this is a helpful thing is found back in the days when the amount of real memory a processor could access was limited to mere megabytes.

The virtual memory system typically works on pages of 4K, which are swapped in and out of real memory as a whole. This enabled a processor that could be limited to just 4MB of real physical memory to address potentially gigabytes of virtual memory, albeit with that data store on a hard drive.

Even today systems with 2GB of memory can easily require virtual memory and with the majority of people running 32-bit versions of Windows, 4GB is the practical physical memory accessible. So while this is a lot of memory, running demanding apps, such as an email client, productivity suite, image editing software, virus checkers and so on – this can simply go.

So with virtual memory still an issue, even for PCs with 4GB of physical memory installed, the original question still stands: what is the best configuration for your Windows page file, if you need one at all?

The plan here is to test a whole range of scenarios, some of them typical and others not so ordinary to reveal the optimal configuration for you.

Next Page: The tests

 

Your comments (6) Click to add a new comment

neilmohr


November 18th 2010

6. This article was originally written May 2009, so excuse me if my memory is fuzzy, but I believe the small page file was 512MB.

Alert a moderator

furiousmrdream


February 6th 2010

5. On your chart you specify "small page" What size was this user defined small page file for 1GB and 6GB of RAM?

thanks

Alert a moderator

neilmohr


October 10th 2009

4. Windows can address up to 4GB of memory, however memory space is reserved for the graphics memory and other hardware peripherals, so usually reducing the available addressable memory to 3.4GB or less. So for most people 4GB of installed memory is still optimal - taking intro account dual memory systems. It is possible to circumvent this using PAE http://support.microsoft.com/?kbid=291988

I believe ReadyBoost only caches application and Windows libraries to help accelerate boot times and application start-up times. General data manipulation or large file loads wouldn't be improved by it.

Alert a moderator

wobblejuice


September 24th 2009

3. How do you create a user-fixed page file and how do you split this over two separate drives?

PS: Your article was difficult to read.

Alert a moderator

unbeta


September 23rd 2009

2. You probably should check your facts on this story. The limit on Microsoft 32 bit systems is 3gb. Anything more gets ignored by Windows. Here's a link that explains it in more detail:

http://www.dansdata.com/askdan00015.htm

Alert a moderator

burninglegion22


September 23rd 2009

1. loved this article. it cleared up alot.

the only thing im left wondering is about "readyboost" which seems very similar to a pagefile or works in conjunction with it i believe. but it does the same function. stores certain things in memory for fast access.

i might be wrong but maybe its something that could be looked into for these tests.

Alert a moderator

Tell us what you think

You need to Log in or register to post comments

By submitting this form you agree to our Terms of Use and so are legally responsible for anything you submit. DO NOT submit anything which may violate the Terms of Use or another person's rights including copyrighted or offensive materials.