Swap File Basics
[ Home ] [ Back] [ Next ]
Information on the use of the Swap File

Introduction 1. Introduction
Settings 2. Settings
Optimizing The 
Swap File 3. Optimizing The Swap File
Defragmenti
ng The Swap File 4. Defragmenti ng The Swap File
Moving The 
Swap File 5. Moving The Swap File
Tracking 
Usage 6. Tracking Usage
Deleting 
the Swap File 7. Deleting the Swap File
Resources 8. Resources


1. Introduction:-
The Win95/98 swap file is named [ win386.swp ] and under Windows 2000 its known as the Page File and is named [pagefile.sys] this is normally listed in the Windows folder. Its presence is essential to allow Windows to run properly. Its function is to act as a fast cache/buffer file. If Windows runs out of physical RAM (for what ever the reason), it swaps the least recently used memory areas to your hard drive and then re-uses the RAM. Example: A program needs data that was just swapped out (for what ever the reason), Windows will swap it back into RAM. It's as basic as that, this is the way the Windows shell was designed. Some programs use the swap file even if RAM memory is available!


2. Settings:-
Windows uses a formulation of your system specs to arrive at these settings, so simply allowing Windows to choose the Minimum, Maximum and Hard Disk values is normally the best thing to do. However, if you have a large amount of RAM say 128MB, then setting the Swap File to a permanent size is feasible. Under Win2000 it might be beneficial to make your own settings particularly if you have a dual boot system say Win9x and Win2000, in this case Windows 9x doesn't recognize NTFS. As a result, you can only really share the Page File when on a FAT32 partition.


3. Optimizing The Swap File:-
There are two things that you can do here. The first is to optimize the Windows cache. The Windows cache allocates a portion of memory to keep frequently-accessed data for quicker reads. The Windows cache file is dynamic in the sense that it can grow and shrink when needed. This can sometimes get out of hand if the size of the cache grows too large, taking up too much of your precious RAM. Edit your system.ini file (using DOS Edit, Notepad, or whatever), and search for the line containing:

[vcache]
minfilecache=xxxxx
maxfilecache=xxxxx

If it is not present, you may manually add these three lines to the end of your system.ini file. Set your maxfilecache to a value roughly equal to ¼ of your actual RAM size (e.g. if you have 64MB RAM, set it to 16384). This is a rough guide, you may want to set it higher or lower depending on your preferences. This value determines the maximum amount of memory that Windows can use for caching. You may set the minfilecache to any lower value, or even set it equal to maxfilecache to obtain a fixed-size cache. Again, it's all a matter of personal choice.

The second thing that you can do to optimize swap file usage is to ensure that you have a contiguous allocation for the swap file (i.e. it is not fragmented). In order to do so, you need a fixed-size swap file.

Set the Swap file Size:
To set the size of your swap file, go to System Properties in your Control Panel, select the Performance tab, and select the Virtual Memory button.

Then set the Minimum and Maximum value of your swap file to the same amount. This value is very dependent on your system's physical RAM and what you do with your system. The amount of RAM plus the size of the virtual memory file is the maximum amount of RAM you can use at once. If you have 8MB, 16MB or 32MB of RAM then the Minimum and Maximum can be set at 2.5 times the size of your RAM. If you have 64MB of RAM then you could set the virtual memory to 200MB no lower than 150MB. If you have 128MB or more of RAM 100MB of virtual memory should be fine. Win2000 must have a minimum of 128MB of RAM. Essentially the Minimum and Maximum size should be larger than the size of your swap file so catch it all! Next defragment your swap file.

Note: The System Properties window lists the amount of RAM in your PC.


4. Defragmenting The Swap File:-
In Control Panel... System Properties... Performance... Virtual Memory, Click to check "Let me specify my own virtual memory settings"

Disable virtual memory.
Reboot your computer.
Run Scan Disk the Thorough test not the standard.
Defrag your system using Disk Defragmenter.
Re-enable virtual memory, and fix the size of your swap file as explained above.
Reboot your computer.

This procedure should ensure that your swap file is in one single contiguous allocation


5. Moving The Swap File:-
The placement of the swap file on the outer edges of the hard disk are claimed to speed up data access. this is true but milliseconds in saved time you will never ever notice. More important is time taken to access the parts of a fragmented swap file.

In Control Panel... System Properties... Performance... Virtual Memory, Click to check "Let me specify my own virtual memory settings"

Disable virtual memory.
Click the arrow next to the hard disk.
Choose the best location for your virtual memory file

  1. Select the quickest hard disk.
  2. If you have, two hard disks that are similar in performance select the hard disk that does not contain Windows system files.
  3. Make sure the drive has free space equal to at least twice the size of the recommended swap file size.
  4. If the partition is on the same physical drive, select the partition in alphabetical order. For example, if you have one 2GB hard disk and you partition it into two 1GB partitions drive C & D) You should pick Drive C over Drive D if meets all the guidelines of 1, 2 & 3.

Click OK and OK again in the System Properties window. A pop up window will appear that says you need to restart windows: Reply No. Don't Re-Boot!! Now you need to run Scan Disk the Thorough test not the standard. Defrag your system using Disk Defragmenter.

Re-enable virtual memory, Now if your going to put your swap file on your C Drive you can leave the Hard Disk setting alone. Else fix the size of your swap file as explained above.

You must restart your computer before the new settings will take effect. Do you want to restart your computer now? Click Yes

Sometimes Windows 95/98 takes a long time to shut down. During this time, it is doing necessary system maintenance. You must wait while the computer shuts down.


6. Tracking Usage:-
If you would like to track the systems swap file usage then, Click Start... Programs... Accessories... System Tools... System Monitor, if System Monitor isn't available in the System Tools Menu, you'll have to install it; use the Wndows setup tab of the Add/Remove Programs applet.

In System Monitor, click Edit ...Add... Edit Item. Choose the Memory Manager group and within it choose 'Swapfile size' and 'Swapfile in use' . Check the Line Charts box the View Menu. Choose Chart from from the Options menu to set the monitors update interval anywhere from once a second to once an hour. Now launch your usual appz do some surfing and you can now monitor the affect on the size of the swap file and the amount of memory that's in use.


7. Deleting the Swap File:-
For those that are security conscious, investing in RAM say 128MB is a good step since using the RAM ensures that nothing is written to disk at all. And once the computer is switched off all data in RAM is lost forever. Simply deleting the swap file whilst Windows is still running or deleting from DOS using the del command just leaves the file there inaccessible, but once windows powers up again it simply re-claims the swap file, including any sensitive data!

The best tool is Scorch, since it generates random garbage when over-writing, rather than strings of 111's or 000's. There are two ways to use this. The first is manual deletion, which is what I will describe here. The other method employs a simple batch file which the author of scorch has named W.bat, using this latter method automates the deletion of the swap file each time you boot into windows, and to allow this you will need to make the swap file size settings permanent.

Manual Deletion
In Control Panel... System Properties... Performance... Virtual Memory, Click to check "Let me specify my own virtual memory settings" Set The Minimum and Maximum values to the same size.
Reboot your computer.

Deleting
You cannot delete Windows\win386.swp while you're in Windows, so you have to restart the computer in DOS-mode (Start, Shutdown, Restart in DOS-mode or restart the computer, press ctrl (F8 on some computers) until you see the Startup Menu, from which you choose Command prompt only).

In DOS, you will probably have a C:> prompt. Assuming scorch is installed on drive c: in a folder named Scorch. Type cd Scorch and press Enter to go to the Scorch folder. Your next command has to be Scorch [c:\windows\win386.swp] and press Enter to delete and overwrite the swap file. After restarting your PC, you will have a brand-new Swap File. Once Windows is up and running. Re-enable virtual memory, and fix the size of your swap file as explained above, or set Windows to manage the swap file automatically.

the author of scorch includes examples and details for creating batch files for use with win3.x, win95 and win98, and describes the necessary steps for swap file deletion which are similar but more extensive than the above.


8. Resources:-
Scorch and Scour:

Home Back Next