On 5 Mar 98 at 10:39, John Chin wrote:
> Ever wonder why people recommend you have a swap file 2.5 times
> the amount of RAM you have? Shouldn't you need a SMALLER
> swap file as you have more and more RAM?
This could be true if the OS went looking for disk space to swap to
only when it urgently needed to swap something out. MS chose to
optimize that (potentially very frequent) operation by allocating
disk swap space whenever an application obtains RAM space that might
need to be swapped. (Memory is typically allocated once, and may be
swapped many times before it is released.) [Pre-allocating a fixed-size
swap file further optimizes this process.]
Therefore, size of swap file needed goes up with application load.
Calculating it from the size of installed RAM is based on two
assumptions:
1. Your installed RAM is reasonably adequate for your typical
application load. If it's not, you should be changing the installed
RAM instead of the swap file size.
2. If your application load always fits into RAM without needing to
swap, you can turn virtual memory off. If not, your swap file
requirement is likely to be >80% of your installed RAM size.
> Microsoft designed their VMM algorithm to require a swap file,
> always. With the 2.5x ratio, one might wonder if there is a direct
> relationship to the percentage of RAM in use to the size of the
> SWAP file (i.e.: Win95 swaps X MB to disk when Y percent of RAM is
> utilized).
It's faster to replace one page in memory with another if you don't
have to write the old one out to disk. So it's a reasonable
optimization for the OS to pre-write pages that don't look very
active to the swap file; there are mechanisms provided by the CPU to
tell, when time comes to replace a page in memory, whether it has
changed since it was last written to the swap file.
David G
|