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)
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. "
Infopackets Top Windows 10 FAQs
How to Upgrade from Windows 10 32-bit to 64-bit
How to Fix: Windows 10 Antivirus Missing, Not Compatible
How to Fix: Windows 10 Display Shifted; Screen Fuzzy
How to Upgrade Windows 7, 8 32-bit to Windows 10 64-bit
to Downgrade from Windows 10
- How to Fix: Windows 10 Upgrade Failed Error C1900208
- How to Fix: Windows 10 Upgrade Failed Error 80240020
- Can I Cancel my Windows 10 Reservation and Reserve Later?
- How to Clean Install Windows 10 using Windows 7, 8 License
- Will Windows 10 Install Automatically?
- Windows 10 Upgrade: Do I have to Reinstall Programs?
- Windows 10 Upgrade: Can I choose 32-bit or 64-bit?
- Which Version of Windows 10 Will I Get (Home or Pro)?
- How to Reserve Windows 10 Upgrade (Free)
- How to Fix: CPU Not Compatible with Windows 10 Error
- Windows 10 Upgrade: Can I keep my Old Windows Install?
- How to Cancel Windows 10 Reservation (Properly)
- Download Windows 10 .ISO (DVD) for Clean Install?
- Microsoft: Windows 10 Will Be The Last Version
- Does Windows 10 require the CPU to support PAE?
- Windows 10: Can I Upgrade or do I need a Clean Install?
Click here for more Windows 10 articles.