Helping people with computers... one answer at a time.

The default setting for virtual memory are typically good enough for most. Tweaking virtual memory settings depends on your computer and what you do.

I have Windows XP Pro SP2 MCE with 2 gigabytes of RAM, to which I just added a 500 MB hard drive to the original 250 MB HD. The new drive is now the primary. Both are 7200 rpm SATA. What do you recommend for a swap file? The "3X RAM" rule of thumb doesn't make much sense. It should be bigger with less RAM, not more. It's currently set to a 2 GB minimum and 4 GB maximum size on the C: drive partition. What size should I set it to, should it be on a different partition, and should I give it its own partition? I will be doing a lot of scanning and Photoshop, if that affects the answer. It's my understanding that a fixed size reduces fragmentation (or at least makes defragmentation easier). I've also seen suggestions for making the swap file an entire partition. (I have Partition Magic.) Would putting it onto the second drive improve read/write speeds? The second drive will be for backing up data files and not in constant use.

You're asking a lot of good questions, and providing a lot of the right kind of data from which to make some recommendations.

I've written about Virtual Memory a time or two already and it does seem like so much voodoo to many people. The same is true for figuring out what to do with it.

But if you're trying to eke out a little more performance from your machine, then it's possible that a couple of settings might help.

First, realize that your swap file really only becomes a performance bottleneck if your system has used up all of your available RAM. There are two important take-aways from that statement:

  • The best way to maintain performance is to make sure you're not trying to use more RAM than you actually have. Run Process Explorer and watch Physical Memory in the System Information viewer. If "Available" becomes small or zero, then consider running fewer programs at once if you can.

  • If you're not using all of available memory, then tweaking your swap file settings isn't going to buy you a whole lot, because it hasn't really come into play.

So let's say that you're running only your image editing software, and you've closed all the other programs that it makes sense for you to close, and you start editing that massive masterpiece. Your available physical memory goes to near zero, and you can hear the hard disk start thrashing as the swap file starts being used heavily.

Now it's time to tweak those settings.

"... there's nothing at all wrong with having a swap file that's too big ..."

I'm not really sure where the "three times RAM" rule comes from. It certainly doesn't apply in all cases. As you point out, machines with less memory may need more swap space or virtual memory in order to be able to run some applications. On the other hand, machines with sufficient RAM typically need less swap space since there's enough RAM to do the job. Sometimes they don't need any swap space at all.

Without knowing how a machine is used I typically set up along these lines:

  • Machines with less than 1 gigabyte of RAM: I set swap space to be roughly three times RAM.

  • Machines with between 1 and 2 gigabytes of RAM: I set swap space to be about twice RAM or perhaps less.

  • Machines with 2 gigabytes or more: I set swap space to be the same as RAM, or sometimes one gigabyte, though there's even an argument for setting it to zero in a case like this.

Note though that I prefaced that with a caveat: I don't know how the machines are being used. This is just a gut-level estimate for average use.

Now, if you want to save time, there's nothing at all wrong with having a swap file that's too big aside from the disk space that it might use. It sounds like you have plenty of disk space, so you could save yourself a bunch of time and just set the swap file to a fixed, maximum size and get on with your life.

If you want to do the analysis, though, then what I would do is set the swap space to be large, run Process Explorer, and watch commit charge in the System Information viewer. Now run your memory intensive program.

Commit Charge will give you a good upper limit of how much memory your system is attempting to use. Subtract from that maximum value the amount of RAM you have and you'll get a reasonable approximation of how much swap space you need. I'd probably round that up by a healthy amount, just to be safe.

For example if on my system with 2 gigabytes of RAM my commit charge ended up being something like 3650meg (3.6 gig, roughly), then I'd subtract off the 2 gig to come up with about 1.6gig. I'd round that up and set my swap space to 2 gigabytes.

If your system does end up using the swap file frequently, placing the swap file on another drive can indeed improve speed. With your system and data files on one drive and the swap file on another, a single hard disk isn't trying to serve up both, and things like disk head movement can be significantly reduced, thus serving up each file more efficiently.

Finally, defragging the swap file can be a problem. It's not done by the normal defragging tools, because the swap file is "in use" while your system is running. You can use the free utility PageDefrag to defragment your virtual memory. (Synonym overload: in this context "paging file" is the same as "swap file" which is the same as "virtual memory".) And yes, once you set it to a fixed size and defrag it, you shouldn't need to defrag it again.

Article C3062 - June 20, 2007 « »

Share this article with your friends:

Share this article on Facebook Tweet this article Email a link to this article
Leo Leo A. Notenboom has been playing with computers since he was required to take a programming class in 1976. An 18 year career as a programmer at Microsoft soon followed. After "retiring" in 2001, Leo started Ask Leo! in 2003 as a place for answers to common computer and technical questions. More about Leo.

Not what you needed?

Recent Comments
14 Comments
KimslanD
September 4, 2008 12:07 AM

You need minimum 50Meg of Swap file for some programs to actually work properly.

You can also set Min and Max to the same value, reducing fragmentation of the swap file.

The swap file ideally should be placed on another drive (not another partition, just in case)

Even with high amounts of Ram (over 3Gig) you can still have a reasonable swap file (say 2Gig Min and Max)

No one seems to have a definitive guide on what amounts to place in the Swap File, as it depends on what you run.

:)

Glenn P.
June 22, 2010 7:35 AM

My pagefile setup?

1Gb RAM, 2Gb Pagefile in a separate FAT32 partition on the main 80Gb harddrive, which is otherwise NTFS (apart from three other small partitions).

Coly Moore
June 22, 2010 8:24 AM

Just a note: Putting it on a separate drive may help performance, but putting it in a separate partition on your main drive will gain you nothing - your main hard drive is still doing all the work, perhaps more because of the need to access the MBR every time...

Glenn P.
July 20, 2010 2:58 PM

This is for Coly Moore:

I put my SwapFile in a separate partition on the same drive for three reasons: (1) so it could be FAT32 instead of NTFS, and (2) to isolate it from the rest of the filesystem, since it is of a fixed size and has no reason to interact with it, and -- most relevantly of all -- (3) I have exactly ONE physical drive -- which makes the placement of the SwapFile partition kind of a no-brainer. Like, "Duh?"     :)

welzki
February 6, 2011 4:26 AM

Me, whenever I fixed a machine I always set the swap file around 4 Gigs. It does improve the performance a lot and my customers are satisfied with it. But before I initiate it I always check if there is a lot of space on the Hard disk drive, if not I set it to 1 Gigs or 2. It depends on the available space on the Hard disk, I just use my common sense. Along with it I also tweak the Visual Effects, set it to Custom and unchecked everything except for the "use drop shadows for icons and visual styles"

Comments on this entry are closed.

If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.

If you don't find your answer, head out to http://askleo.com/ask to ask your question.