Disable/resize Windows Vista disk cache to increase free RAM

9,215

Solution 1

I have ... a swap-less system

I used to think the same way. I've since learned that, in MS Windows, this is a bad idea and can actually hurt performance.

Windows thinks of RAM more as an optimization layer over the hard disk. It doesn't want to wait until you have to swap RAM out before paging/swapping it to disk. Instead, Windows wants anything you put in RAM to already be paged/swapped.

This way, when Windows needs the RAM for something else, it can just use it. This strategy works because it places the (slow) disk writes at the points when your computer is less stressed, at the expense of slightly slower application loads and maybe paging some things it doesn't need to, rather than at the point when your computer is already more stressed and running low on RAM.

Of course, by removing the paging file completely you might tend to think that you get the best of both worlds. However, there's loads of code in Windows that is optimized assuming the performance model I just described. You're really better off making sure you have at least as much swap space as you do RAM.

Solution 2

By default, Vista (and later) x86 will only allow 2 GB of virtual memory for each process. If one application needs more, for example 3GB, you can increase this by :

bcdedit /set IncreaseUserVa 3072

However this will only work for executables that were linked with the "large address aware" flag. Processes running other exe's will still be limited to 2 GB.

Real RAM is allocated as required for both applications and the system.

As this doesn't seem to be your problem, then to optimize the usage of memory one can first Disable SuperFetch on Windows Vista :

The SuperFetch service in Windows Vista preloads your system’s memory with the applications that you use most often. This makes launching of those applications much faster, but it might be an unwanted behavior for system tweakers or gamers.

Secondly, to control the disk cache size, AnalogX CacheBooster is a free tool that is said able to tweak the hard disk cache (never tried it myself), but I'm not sure that it will help, in view of the info below.

As described in Windows Vista Memory Tweak Guide, the disk cache parameters reside in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management

Some important parameters are :

DisablePagingExecutive controls how inactive kernel-mode drivers and system code can be released from RAM and paged to the Page File. Unfortunately, you don't have a page file so system code never gets swapped out.

LargeSystemCache controls the size of the file system cache as follows:

  • 0 (Default) a standard sized file system cache is allocated (less than 10MB RAM)
  • 1 enables the use of a large file system cache (up to total RAM amount minus 4MB!)

If this value is zero in your case, then the disk cache is already as small as it can get. If the performance you get is not satisfying, then you must invest in hardware : either more RAM or a faster hard disk. Increasing RAM from 3GB to 4GB will only get you an increase of (1GB - video-memory), unless you also pass to a 64-bit version of Windows.

Share:
9,215

Related videos on Youtube

user3219303
Author by

user3219303

Programming enthusiast, enjoying coding at home and at work too. I also like computer and console games. But I also have a real life too :D ! I like going to pub with friends, metal music shows, photography, driving and cycling. And I'll be subclassing myself and my wife soon (NewAddition : Me, MyWife)

Updated on September 17, 2022

Comments

  • user3219303
    user3219303 over 1 year

    I'd like to decrease my cache size, because I have a slow disk and run a swap-less system (it's pretty snappy that way). I have x86 Vista and 3 GB RAM. The problem is that Windows eats about 1 GB RAM for disk cache (shown in Task Manager under Physical Memory -> Cached), that leaves only 2 GB for applications. A very annoying pop-up pops up every time when Windows thinks it's low on memory and of course apps crash when the memory is used. But there's still 1 GB sitting in the cache!

    I've tried AnalogX Cache Booster, but it didn't do anything, memory usage stays the same, warning pop ups are at the same levels.

    • stijn
      stijn over 13 years
      won't decreasing cache also decrease snappiness?
    • user3219303
      user3219303 over 13 years
      I define snappiness as responsiveness between switching applications. As swap file is already off, all of them are in RAM - lightning fast switch. I'm willing to sacrifice disk I/O speed for it
    • UNK
      UNK over 13 years
      @Axarydax; That's not how it works, disk cache can be dropped straight away, you're not actually losing any RAM at all. If you're getting low RAM warnings, it's not because of that - I ran Vista on 2GB of RAM, and never saw a low RAM warning.
    • user3219303
      user3219303 over 13 years
      @Phoshi - it was because you had swapfile on.
    • UNK
      UNK over 13 years
      @Axarydax; Perhaps you should turn yours on, then. You can't have both an entirely RAM based system, and run more applications than you have the resources to maintain.
    • user3219303
      user3219303 over 13 years
      I'm starting to suspect Windows Vista's Superfetch is the culprit here...
    • David Schwartz
      David Schwartz over 6 years
      "that leaves only 2 GB for applications". This is not true. The memory used for a disk cache is available for applications. This question is based on the misconception that the pop up is warning you that you are running out of RAM and thus more free RAM will help. But read it closely -- it's not about RAM at all.
  • user3219303
    user3219303 over 13 years
    The system is a lot less responsive when using swap file. I have a good laptop, but with hellishly hard disk, and when I have multiple instances of Visual Studio, browser with lot of tabs, VM or two, database management studio, things tend to swap a lot. And switching apps becomes a long wait. Without swap files, everything's instant. That's a win for me.
  • user3219303
    user3219303 over 13 years
    The IncreaseUserVa switch controls the virtual memory space allocated to each program. It does not have any effect on the way that the physical memory within the system is handled. That is, this switch controls the amount of memory that individual programs can make use of, not the amount of memory that the system can use.
  • Joel Coehoorn
    Joel Coehoorn over 13 years
    Now you discover a limitation of a swap-less system. If you have multiple Visual Studio instances and several browser tabs, you need more RAM than you have.
  • harrymc
    harrymc over 13 years
    I believe you are wrong : See my edit.
  • user3219303
    user3219303 over 13 years
    that's why I'm getting an 8 GB RAM system in a while. I just need to survive on this machine for a while :-)
  • harrymc
    harrymc over 13 years
    I think I misunderstood you, so I rewrote my answer.
  • CausingUnderflowsEverywhere
    CausingUnderflowsEverywhere almost 8 years
    Unfortunately this answer is not very useful anymore at this date (if you're on tablet well maybe you want a small one but it'll be bad for the ssd), I have 16GB of RAM for a very low price. Have been using the PC for a year and not a single time have I ran out. There is just no reason to bottleneck your hard disk with a pagefile anymore.
  • Jamie Hanrahan
    Jamie Hanrahan over 5 years
    Re the advice to "disable SuperFetch": SuperFetch does not in any way add to the amount of RAM reported as "Cached"! SuperFetch uses RAM that's already been put on the Standby page list (after being removed from processes). The SPL is already counted as part of "Cached". After using that RAM to cache file contents, SF leaves it on the Standby page list, so it's still counted as part of "Cached"! So all else being equal, disabling SuperFetch will not change the amount of RAM reported as "Cached"! That RAM is just used for a different sort of cache (a file cache rather than a page cache).