Swap file optimization?
" Dear Dennis,
How can I get my swap file to empty when I start my computer? When my system boots up, a dialogue window appears and reports that I have 572meg in my swap file. Could this be why my computer is running so slow? I use win98se.
A techie friend of mine suggested that I write a simple batch file [program] so that my swap file is deleted every time I reboot the computer. That way, it will be replaced with a new swap file that is empty once Windows is loaded. I don't know anything about this and certainly don't want to play with something I don't know anything about! Any help will be greatly appreciated. Thanks! "
Side note: A swap file is a file set aside to temporarily store information once system memory (RAM) on the computer runs low. Since a hard disk drive is much slower than system memory, a frequently accessed swap file can severely deteriorate system performance. (Source: Orielly.com and members.aol.com)
Unfortunately, what your friend said is incorrect. You're much better off defragging your drive and setting the page file to 1 constant size. This will prevent the swap file from fragmenting, plus acquisitioning the file will be done in a much more efficient manner.
Defragging: How it works
The defrag process will attempt to place the swap file in side-by-side [contiguous] clusters on the drive so that access time (to the file) will be quick and efficient.
As I have discussed in the Gazette a few times before, a single file can span across multiple areas on a hard disk drive. If the file is fragmented, the hard drive heads must move back and forth to read or write each portion of the file (as seen in the picture above). This is referred to as hard drive latency or access time. Defragging, on the other hand, puts related files in a close proximity so that when they are accessed, the drive head efficiently moves (at best) in 1 direction. The drive arm is referred to as the "boom", and a move in one direction of the boom is referred to as a "sweep".
On a side note: Contrary to what your friend suggested, deleting the page file at boot up will only worsen system performance. As soon as the page file is deleted at boot up, new files will overwrite the sectors of the drive where the swap file once occupied. When the swap file is created again, parts of the file will be written to the first available blank areas of the drive (which are typically sporadic). The swap file therefore becomes even more fragmented, resulting in increased latency.
To change your swap file settings (also known as virtual memory):
- Boot into safe mode
- Run defrag on the drive letter that has Windows on it
- Go to the Desktop, right-click My Computer and select Properties
- Go to memory settings (Advanced -> Performance Settings -> Advanced -> Virtual Memory Settings in WinXP) set the page file to 2.5x the size of RAM in your computer. For example, if you have 256 meg, set the page file to 640 meg.
I remember reading this formula somewhere, and have tried it myself on a few machines and it has worked well for me in the past. However, as Gazette Reader Curt W. points out, computers today typically have more than 512 megabytes of system memory (RAM), and so a new 'rule' comes into effect:
" The 2.5x rule as you mentioned, is a bit out-dated. As a rule of thumb, I wouldn't go higher than 500MB unless you are monitoring your system and know for a fact that you need to set the size higher than that. With RAM memory commonly reaching 512MB or greater in PC's these days (I personally have 1GB in my machine) it would be absurd to set the swap file to anything more than 500MB unless you're using super memory-hungry applications. "
Free guide: Windows 7 -- Free Quick Reference Card. Ask any pro computer user and they'll tell you: having to constantly reach for the mouse not only causes strain on your neck and back - it also slows you down. Imagine being able to control your computer the way it was meant to be - using your keyboard! With this guide, you'll learn to dramatically increase productivity using the best ways to navigate, organize, and manage your Windows PC and its contents. Most importantly: the majority of these shortcuts, tips, and tricks are valid for any PC, netbook, and laptop running Windows XP, Vista, and 7. Use it to brush up on the basics and to find alternate methods to your favorite commands. This printable quick reference guide is yours to use, distribute, and share! Click here to download this guide now! Note: this guide is free, but registration is required; after that, you can select more ebooks and videos for download without registering again. If you have questions / problems with the registration form, please read this.