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.
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.
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.