WINDOWS 95 VIRTUAL MEMORY AND VIRTUAL CACHE-A DISCUSSION
By: Mark Stotzer
The terms "Virtual Memory" and "Virtual Cache" (vcache) are used frequently in Windows 95 newsgroup discussions. The function of both of these concepts in Windows 95 is related. At times, however, these terms are confused, abused or misused. To assist our ongoing discussions-allow me to attempt to clarify just what they are.
Virtual Memory: This feature allows part of your hard drive free space to become an extension of your RAM directly accessible by the CPU. The classic definition of "Virtual Memory" is basically the memory "address space" of the CPU. For any computer system it should be:
Total Virtual Memory=Total RAM+other memory (hard drive space, etc)
However, the term is twisted a bit by Microsoft with respect to Windows. The term "virtual memory" in most Windows notes usually means the size of the swap file. (Note: they also call it a "Page File"). So then, let me define a new term "Total Memory." In Windows 3.x running in the "386 Enhanced Mode"
Total Memory=Total RAM + size of the Permanent Swap File
In Windows 95, because it views all free drive space as a potential swap file it is:
Total Memory=Total RAM + Most of the free drive space on the swap file drive
- In Windows, as you keep loading applications, eventually your actual RAM starts filling up. As your RAM gets close to full, things start spilling over into the swap file. This is why you may observe what may appear to be "random" disk accesses while you are working in Windows-especially Windows 95.
-
In Windows 3.x "Enhanced Mode" and Windows 95 there exists a "Swap File."
-
This special file was of fixed size in Win3.x ("Permanent Swap file") when you ran in the "386 Enhanced Mode" but is dynamic (allowed to grow and shrink) in Windows 95.
-
In Win95 you can go into Control Panel/System/Performance/Virtual Memory and set the Min/Max size of the swap file.
-
There many "rules of thumb" floating around on the internet newsgroups whether to manually set the size of "Virtual Memory" (The swap file) in Windows 95-I will try some of them and report my results here. NOTE: Setting the virtual memory size via Control Panel/System/etc. is NOT where the vcache disk cache size is set-see the Virtual Cache section below!
-
I do not mess with this swap file setting. I let Win95 handle it for now. I hope to test different manual settings in the near future.
Virtual Cache: This feature, found in Windows for WorkGroups 3.11 and Windows 95, sets aside a portion of your RAM to cache (keep a temporary copy) of any reads or writes of programs and data from/to your hard drive.
- To see any disk cache at work:
- Run any application not already loaded (hard drive light flickers).
-
Close it.
-
Run it again (now no hard drive light flicker or very little) -came up faster didn't it? That is because the second time it loaded the program from the cache in RAM and not from your hard drive!
- Vcache performs the same basic function that SMARTDRV does in DOS-it watches things going to and from the hard drive and keeps a copy of most used data in it's space of RAM.
-
With SMARTDRV in DOS the "rule of thumb" was to create a cache in RAM of 2MB of RAM if you had an 8MB system. This means that 2MB of your RAM was "fenced off" for the disk cache to use only. The rest of your programs could thus only use the remaining 6MB.
-
The default size at any given time, of the vcache in Windows 95 is not published anywhere. I suspect it is usually too large. To set the Max/Min size of the virtual cache you must edit your SYSTEM.INI-Look for the [vcache] section in the file and add or modify these lines:
MaxFileCache=
MinFileCache=
I use Max=1024 and min=512 for my 16MB system. I'm still experimenting with the settings-as are many of you! Right now 1024/512 seems to be my system's sweet spot. Never set the Min=0! In my own testing it causes swapping to occur even sooner!
- What are the things to watch out for in using any caching program?
- Making the cache so small it is useless.
-
Making it too large so that the CPU spends too many cycles trying to keep the cache full.
-
Additionally, in the case of Win95 making the cache too large can result in the "spillover" of data into the swap file to occurring sooner.
How are Virtual Memory and vcache related? If, as I suspect, the default settings for the Win95 vcache are too large (I've read Win95 tries initially to use all free RAM as the vcache) then:
- You will get many more of these random hard drive accesses because too much RAM is being set aside at times for the vcache. This symptom seems to also extend to computers with 32MB and more of RAM.
-
You may also get the effect noted above-Win95 might be shuffling data of to the swap file to keep a bigger vcache. The are no details anywhere as to just what formula Win95 uses as its defaults-so, for now, we are all left to experiment!
-
I think most of us have seen that the Win95 default memory management scheme at times in "normal use" does not work as well as it could or we would not be making so many new friends having these discussions!
Observations and Testing
- The Windows 95 memory manager seems to give priority to maintaining the vcache size at the expense of allowing data to be sent (prematurely?) to the swap file. In other words, rather than reducing the cache to some minimum level, the memory manager starts swapping as you load more applications and RAM begins to fill up.
-
Many applications and even Windows 95 itself are "sloppy" cleaning up RAM and freeing up or releasing RAM space after the apps are closed. I've monitored two systems and seen that a residue of occupied RAM seems to always remain after closing almost all apps.
-
I tend to agree with some respondents to my newsgroup posts on these who seem to have determined that Win95 tries to, at first, set aside about 1/4th (4MB cache for 16MB of RAM) of RAM for the vcache. Those same folks think that about 1/8th of RAM should really be the figure. I agree with this except for 8 and 16MB systems where RAM is really tight.
For further Reading: Go to Microsoft's Knowledge Base pages and retrieve read/print these articles related to file system performance in Windows 95: Q140679 and Q138012 (This one talks about a BUG!).
Back to the Main Help Page