About Window's Virtual Memory System

Many Windows users are confused about how the Virtual Memory system works 
and what settings are appropriate.  Understanding how Virtual Memory works 
helps you configure your machine for the best possible performance. Most 
Windows users can simply use the defaults that came with their machine and 
live happily ever after. 

This document helps you understand what your Virtual Memory settings are, 
and why they are set that way. You may discover upon reading this document 
that you want to change your Virtual Memory settings. All the information you 
need to know to make an intelligent change is included here.

Two values determine how much linear address space you have for applications 
(linear address space is what Windows reports as "Memory" in About Program 
Manager). These numbers are the Swapfile size and the PageOverCommit value.  

To check or set the Swapfile size, open your Main program group from the 
Program Manager. Doubleclick on the Control Panel icon, then doubleclick 
again on the 386 Enhanced icon. Click on the Virtual Memory button. You should 
now see your current Virtual Memory settings.

Swapfile size is what determines how much disk space is set aside to 
supplement the RAM in your machine.  Using a permanent Swapfile always 
provides the fastest system performance.  Also, if you have Windows 3.1, 
the option to "Use 32-Bit Disk Access" improves Virtual Memory's speed.  
(Unfortunately, 32-Bit Disk Access does not work on all machines, so unless 
you know whether your machine supports this, you either have to try it as 
an experiment, or not change it.  To experiment adequately, you must heavily 
exercise Virtual Memory with this option On; it is not enough to see that 
the machine successfully boots.)

If your Swapfile type is not Permanent (i.e., either Temporary or None), 
change it to Permanent. To do this, click on the Change button in the Virtual 
Memory panel you opened earlier. Use the popup to set the Swapfile Type to 
Permanent. Next, you need to set the size of the permanent file.  Windows 
recommends a Swapfile size. In most cases, this recommended value should be 
used.  Setting aside more disk space creates empty disk space that is never 
used. Setting aside a smaller than recommended Swapfile saves disk space, 
but actually wastes RAM -- Windows continues to use real memory to track the 
full recommended Swapfile size.  Instead of choosing a larger or smaller 
file than the one currently recommended, the real trick is to get Windows 
to make the recommended size more in line with the size you want it to be.

So, how does Windows determine the recommended Swapfile size?  When Windows 
starts, it calculates how much memory it has available, and multiplies that 
number by a value, called the PageOverCommit value.  The default value of 
PageOverCommit is 4. This means that Windows multiplies the available RAM 
by 4, builds memory tables with enough entries for 4 times the RAM, and 
recommends a Swapfile size of 4 times the available RAM.  On a typical 8MB 
machine, the amount of Windows application memory might range between 4 and 6 
MBs, meaning that the recommended Swapfile size falls somewhere between 16 
and 24MBs. If you don't set aside a permanent Swapfile of the recommended 
size, the RAM used to hold the memory tables goes unused. It takes about 12K 
of RAM memory to keep track of each 1MB of disk drive space. Thus, if you 
undercut the recommended file size by, let's say 10MB, there will be 120K of 
real RAM that is never used. At today's memory prices, you've just wasted $5 
or more.

To use a different size Swapfile than recommended, adjust the PageOverCommit 
value to a value between 1 and 20. You do this by adding a line to your 
SYSTEM.INI file (in your Windows directory).  In the [386Enh] chapter of 
SYSTEM.INI, add the line

   PageOverCommit=x
   
where x is the value to multiply your RAM size by. For example, on an 8MB 
machine we got a suggested size of 23,664MBs, but only wanted to devote 
about 12MBs of the hard disk to Virtual Memory. Therefore, we set the 
PageOverCommit to 2 (half of the normal 4, since we wanted to use about 
half the disk space).  If you feel that Window's recommended Swapfile size 
is too small, increase the PageOverCommit value from its default of 4.  
If you feel it is too large, decrease it.  Then restart Windows and set 
the Swapfile size to the new size it recommends.

A few other things can limit the recommended Swapfile size -- Window's 
recommended permanent Swapfile size is never larger than the available space 
on the disk, for example.  So if the recommended space would have been 20MB, 
but there are only 10MBs available on your disk, Windows recommends a 
Swapfile size of 10MBs, not 20.  Another limitation that may not be quite so 
obvious is that a permanent Swapfile must be made from "contiguous" disk 
space -- space that is all clumped together in one place on the disk and not 
spread out in a random pattern over its surface.  If you increase your 
PageOverCommit value and find that the recommended size does not increase, 
you need to run a program like Norton Utilities or the Defrag utility in DOS 
to defragment the free space on your hard disk (or, if you have more than one
drive available, you could select another drive for the Swapfile).

Note that having more linear address space (i.e., more Virtual Memory) and 
having more RAM are not the same thing. More address space lets you run more 
programs simultaneously, but a single large application that uses more memory 
than you have physical RAM will run slowly.  At a minimum, you should 
purchase enough real RAM for the single largest application you need to 
run regularly. For example, Adobe Photoshop recommends 10MBs of RAM to run. 
This is the minimum amount of real RAM you should have. 

Finally, note that when you get an "Insufficient Memory" message, it is 
unlikely that you've run out of linear address space.  Far more typically, 
it is some special area of memory (memory under 1MB, or System Resource 
memory) that is in short supply, not linear address space.  These other 
limitations are the elements that RAM Doubler from Connectix specifically 
corrects.  Thus, you shouldn't immediately tinker with your Virtual Memory 
settings when you get an out of memory message. Check first to make sure 
that About Program Manager reports that you've really used all your memory 
(i.e., reports 0K free). Then and only then you'll want to increase the 
linear address space as indicated above.

In summary:

* It is ALWAYS best set your Virtual Memory Swapfile to the recommended size, 
using a permanent swapfile.  

* If you need MORE linear address space, change the PageOverCommit value in 
SYSTEM.INI to a higher value (up to 20; note the default is 4). After 
restarting Windows, set your Swapfile to the new recommended size.

* If you find that the recommended Swapfile size is TOO LARGE, you can save 
12K of real RAM for each megabyte of disk space no longer used by setting the 
PageOverCommit value to something smaller than the default of 4.  After 
restarting Windows, set your Swapfile to the new recommended size.


