Swap Files & Memory




















I could use more available memory?  What about programs that free-up memory without rebooting?

One thing to remember is that from the system's point of view, free RAM is just going to waste.  I don't know the specifics of memory management in the OS, but so long as the RAM is available there is no reason not to let the disk caches grow, to let each process keep expanding its working set, and so on. RAM is a valuable resource and the system should be biased to keeping all of it in use. It is only when RAM gets over committed that things get interesting and the system has to start making choices about who gets what.
-Joe Fromm

Actually, these program do very little other than shrink caches, which actually slows the machine down.  It is true that some programs can leak memory. Windows (95 and higher) itself will free all the memory that the program allocated once it is shut down. Windows dynamically allocates disk and other caches based on load. "Free" memory is actually memory that is being wasted, this is what most people find illogical. The reason the "free" memory shrinks after using programs for a while is that certain DLLs and filesystem locations have been recognized as repeatedly accessed, therefore important to store in fast ram instead of slow disk. Windows continuously analyzes what is going on and keeps the most accessed stuff in ram. I find that after "compacting" or "freeing" memory with one of these programs my system actually runs slower until Windows can grow it's caches again.
-Jon Ort

Right on, brother! Free memory is a BAD thing.  One comment I would add to your excellent post: Win9x will free memory associated with 16 bit tasks when the last 16 bit task is closed. So, if you are running a bunch of old 16 bit apps that don't free their own memory properly, you can have some memory tied up doing nothing.
-Bill Clay

One more thing, we could talk swap files here


There are as many opinions about how to manage a swap file as there are people using Windows, but there are a few facts:

1) You can let Windows manage your swap file for you.  For Windows 98 and above, this will work reasonably well for most people.

2) Fragmented swap files can slow windows WAY down.

In order to permanently prevent fragmentation of the swap file, set the smallest file that Windows will operate with, then clean and defrag the hard disk where the swap file resides (you may need to defrag several times). Now manually set the swap file to the proper size (this is where most of the differing opinions are). I have 384 MB of RAM on my home machine and set a minimum swap size of 768MB with a max of 1.5GB (Win2K). This assures that the first 768MB are clear of fragmentation but allows Windows to grow the swap if needed. I set such a large size because I sometimes edit very large images with PSP.

You can also use a commercial defragger (the only good one I know of is DiskKeeper, but that does not mean there are not others). It can defrag the swap file but it has to do it by a boot time defragmentation run which can take a very long time on a heavily fragmented drive.

When using PSP I can quickly tell if a drive is heavily fragmented, it makes that much difference.

It raises a question that perhaps someone could answer: "In order to permanently prevent fragmentation of the swap file, set the smallest file that Windows will operate with, then clean and defrag..." If one shrinks the swap file to the point where Windows won't operate, how does one increase it again? -Fred

Good question.  If you have 128 or more MB then you should be able to set zero size swap file. Anything less and set the swap file to 64mb. This should generally work. For most versions of windows you can boot into safe mode and reset the swap file size back up if it won't boot in normal mode.

Have a look at http://www.oo-software.de they offer a fine defragmenter that actually gives better results than Diskkeeper (very fascinating on full disks, large disks and when run the very first time). -Michael

 Copyright ©2001 Top10 All Rights Reserved