Connect with us

Hi, what are you looking for?

Computer Tutorials

Managing the Windows Swap File

What is the Windows Swap File?

To execute a program in Windows, it first needs to be loaded into memory (RAM). Windows lets you run multiple programs simultaneously and chances are that they won’t all fit into memory at the same time. For that purpose, Windows uses what is called Virtual Memory to simulate RAM, pretending it has more memory than what is actually build into the PC. It does this by moving data from real memory to a special file on the hard drive, called the Windows swap file in Windows 95/98 or page file in Windows NT. This, in effect, allows Windows to address more memory than the amount of physical RAM installed. Without it, we would not be able to run windows on machines with limited RAM. For example, think back to when Windows 95 first came out, the average computer had 8 to 16 Mb of Ram. It would not have been possible to run Win95 and applications without using virtual memory. Program code and data are moved in pages (memory allocated in 4K or 16K segments within a 64K page frame) from physical memory to the swap file. As the information is needed by a process, it is paged back into physical memory on demand and, if necessary, windows may page other code or data to the swap file in its place.

Swap-File size changes

By default, windows manages the swap file dynamically, meaning that Windows increases and decreases its size as needed. For most users it is recommended to let Windows manage it to ensure that there is always sufficient memory addressing for applications and processes. The advantage of a dynamic Windows swap file is that it does not permanently make hard disk space unavailable, it can only grow if there is sufficient disk space. When you shut down, the swap file is being deleted. It is re-created again when Windows is started. The disadvantage of a Windows managed swap file is that it becomes fragmented, and performance can be lost due to frequent resizing as your computer is performing memory intensive tasks. Fortunately, educated users of Windows can specify their own virtual memory settings if they deem it necessary.

How To Specify Your Own Virtual Memory Settings

You access these settings from within the System Control Panel applet. The easiest way to get to that from the Desktop is to right-click on the My Computer icon and choose Properties from the menu. Another way is to click Start/Settings/Control Panel/System. Click the Performance tab and click the Virtual Memory button.

If you see this for the first time, the option Let Windows Manage my virtual memory is probably selected and the other fields are grayed out. Click the Let me specify my own… and choose the drive you want to put your swap file on by clicking the drop list in the Hard Disk field and state the minimum and maximum swap file size in the appropriate fields.

Advertisement. Scroll to continue reading.
AIAD

What Settings To Specify?

Most importantly, you do not want Windows to run out of memory, so make sure that the size you specify will be sufficient. Base your decision on how much RAM you have, and how demanding your applications are. A good way to get a handle on this is to monitor free physical memory, swap file size, and swap file in use. Install System Monitor from Add/Remove Programs in Control Panel. Click the Windows Setup tab and highlight the System Tools category and click Details. Put a check in System Monitor and click OK and then OK again. You will be prompted to insert your Windows CD. After you get System Monitor installed, open it by going to Start/Programs/Accessories/System Tools and go to Edit and choose Add Item. Click the Memory Manager Category and choose the items above. Use this utility for a while to monitor what Windows is doing while you run your applications.

Choosing the Drive

If you only have one hard drive, obviously there won’t be another one in the list to choose from. In general, choose the fastest drive for your swap file. If you have a second hard drive, and it is on the Second IDE controller (Secondary Master or Secondary Slave) you should choose that drive for your swap file to reside on. The reason for this is, modern Dual PCI IDE controllers on Pentium motherboards allow simultaneous access to two drives on separate IDE channels. The technical term for this is Peer Concurrency. Drives on the same IDE channel cannot be accessed simultaneously (and also, the read/write heads on a single drive can’t be in two places at once). The benefits of having your swap file on a drive on the second IDE controller should be obvious: Windows will be able to work from the C: drive AND page to and from the swap file on the other drive at the same time! If your system uses the swap file often, this will increase performance significantly.

Setting the Windows Swap File Size

There are advantages to setting a fixed swap file size (that is, equal minimum and maximum settings). The swap file will be a static size, which means that it can occupy contiguous cluster chains and not become fragmented. Another advantage is that since it is always the same size, Windows doesn’t have to take the time or resources to resize it. This will improve access time. The disadvantage of a fixed size swap file is that it cannot grow beyond the maximum if the need arises. If you want to have the best of both worlds, a swap file that doesn’t grow and remains contiguous, yet can be increased if you inadvertently bite off more than you can chew performing some memory intensive graphics editing operation or something, then choose a minimum size that is large enough that it will never need to be increased. For example, if you set a minimum of 128 Mb and a maximum of 500 Mb, you should never see the swap file size increase, but more will be available to Windows should something bad happen. Again, System Monitor is an excellent tool to use in making this decision.

Advertisement. Scroll to continue reading.
AIAD
Click to comment

You must be logged in to post a comment Login

Leave a Reply

You May Also Like