Under Windows NT, Windows 2000 and XP the file cache can theoretically take nearly all the physical RAM. The upper limits are 512 MB under NT4 and 960 MB under 2000/XP.
Often it seems that the memory of applications is swapped out in favor a large file cache. If you need the application again you see and hear how it is digged up from the pagefile...
Under Windows 9x you where able to limit the size of the file cache thru an entry in the SYSTEM.INI. But there is no similar way under NT, 2000 and XP.
It becomes really worse when a Windows optimizing tool has set 'LargeSystemCache' to 1. This means
something like "If Window needs memory, take it from anywhere but not from the file cache".
The only way to get a bit control over the file cache is to trim its 'Working Set'. The Working Set is the memory that has been recently used so Windows expects that it is used again in the near future.
Trimming the Working Set doesn't mean that the memory is taken away from its owner. It only means that the Windows memory management thinks that it's not important to hold it in physical RAM.
Trimming the Working Set of a program is also made by Windows whenever you minimize the program. You can observe it in XP's TaskManager "Mem usage" column. Since Vista it shows it under its correct name.
Trimming the file cache's Workting Set is what Sysinternals
CacheSet does. But it does it only on a button click.
That's why I've made NtCacheSetter which does't it periodically. It bases upon the sources provided by SystInternals.
Sample for a commandline of NtCacheSet to trim once a second to a minium of 8 MiB, a maximum of 64 MiB and showing its window:
NtCacheSet /int=1s /min=8M /max=64M /show=1
/int sets the interval in milliseconds or with unit s (Seconds)
/min sets the minimum value in Bytes or with unit KiB, MiB, GiB (K, M, G are good enough)
/max sets the maximum value in Bytes or with unit KiB, MiB, GiB (K, M, G are good enough)
The default values are 1 Second for the interval, 1/16 of the physical RAM for the maximum and 1/4 of the maximum for the minimum.
Start NtCacheSet again to remove a previous invisible instance from memory.
The periodic cache set call is performed only if the current cache working set size
is at least 10 percent above the maximum value. In the window this is indicated
by the 'LED':
Gray : Idle
Green: Values checked but cache not adjusted
Red : Values checked and cache adjusted
For testing with different values you can click them and enter new ones in an inputbox.
Yes, that's a bad GUI design.
I'm not sure if this tool is useful, but I think so, especially since Microsoft introduced a function for permanently limiting the file cache with Windows 2003 Server SP1.
But periodically trimming the cache's working set is no good solution. Let's call it an experiment...
Here is an interesting article from the "Windows 2000 Performance Guide":
File Cache Performance and Tuning
|