Swap file optimization?
Speaking of Windows optimization, Infopackets Reader 'Harkatcan' asked me a very interesting question the other day that dealt with the Windows Swap File.
" 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)
My response:
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 Infopackets 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. "
Most popular articles
- Which Processor is Better: Intel or AMD? - Explained
- How to Prevent Ransomware in 2018 - 10 Steps
- 5 Best Anti Ransomware Software Free
- How to Fix: Computer / Network Infected with Ransomware (10 Steps)
- How to Fix: Your Computer is Infected, Call This Number (Scam)
- Scammed by Informatico Experts? Here's What to Do
- Scammed by Smart PC Experts? Here's What to Do
- Scammed by Right PC Experts? Here's What to Do
- Scammed by PC / Web Network Experts? Here's What to Do
- How to Fix: Windows Update Won't Update
- Explained: Do I need a VPN? Are VPNs Safe for Online Banking?
- Explained: VPN vs Proxy; What's the Difference?
- Explained: Difference Between VPN Server and VPN (Service)
- Forgot Password? How to: Reset Any Password: Windows Vista, 7, 8, 10
- How to: Use a Firewall to Block Full Screen Ads on Android
- Explained: Absolute Best way to Limit Data on Android
- Explained: Difference Between Dark Web, Deep Net, Darknet and More
- Explained: If I Reset Windows 10 will it Remove Malware?
My name is Dennis Faas and I am a senior systems administrator and IT technical analyst specializing in cyber crimes (sextortion / blackmail / tech support scams) with over 30 years experience; I also run this website! If you need technical assistance , I can help. Click here to email me now; optionally, you can review my resume here. You can also read how I can fix your computer over the Internet (also includes user reviews).
We are BBB Accredited
We are BBB accredited (A+ rating), celebrating 21 years of excellence! Click to view our rating on the BBB.