How could I limit or even disable file cache on Windows Server 2008R2?

53,125

Solution 1

The whole point of the cache is that it uses unused ram, and gives it up as soon as an application requests more. Thus, you don't want to limit its size as doing so would just leave the free ram completely wasted.

Solution 2

You have to call the system API SetSystemFileCacheSize()
Documented here: http://msdn.microsoft.com/en-us/library/aa965240.aspx

Some GUI programs allow it: http://technet.microsoft.com/en-us/sysinternals/bb897561
But you may prefer CLI, to automaticaly run it at system startup: http://www.uwe-sieber.de/ntcacheset_e.html (look in the middle of the page, it works for 2k8)

Or just write a powershell script calling SetSystemFileCacheSize()

Note it is strongly discouraged to disable the cache for production use.
It is frequent to limit the cache size to a small value for virtualized machines, not to disable it.

Solution 3

We have also experienced this issue on Windows Server 2008 R2 in our company. In our case the machine got totally stuck. It seems to be a bug on this server version of Windows, because it did not occur under the same circumstances either on my much smaller Windows 7 machine running in VirtualBox, or under Linux.

You can set the cache to a certain limit with an API as others have already posted, but you can find applications to directly use it, such as SetSystemFileCacheSize.exe or NT Cache Setter.

The downside is that you need to set the cache after every reboot. You can also flush the whole cache in one go with this.

We set the file cache on our VM having 14 GB RAM to 4 GB and it works. Also flush works nicely and you can see it directly in Task Manager.

Command line samples:

  • Show the current Windows settings:

    SetSystemFileCacheSize.exe
    
  • Show help:

    SetSystemFileCacheSize.exe /?
    
  • Set the minimum size to 8 MB and the maximum size to 128 MB:

    SetSystemFileCacheSize.exe 8 128
    
  • Disable minimum size and set the maximum size to 128 MB:

    SetSystemFileCacheSize.exe off 128
    
  • Disable minimum and maximum size:

    SetSystemFileCacheSize.exe off off
    
  • Flush the file cache:

    SetSystemFileCacheSize.exe flush
    

Note: The tool must be started with admin privileges.

Share:
53,125

Related videos on Youtube

Apache
Author by

Apache

Updated on September 18, 2022

Comments

  • Apache
    Apache over 1 year

    There is a machine, with a very fast RAID array, and a fast internet connection. But, it only got 8gb of mem, which runs out really quick, when the upload goes up.

    Any ideas how could I disable, or limit the cache?
    (I have tried disabling Write Cache from Device Manager. But that's just write cache, and it didn't help.)

    • Admin
      Admin almost 12 years
      Any relation to this? superuser.com/questions/415140/…
    • Admin
      Admin almost 12 years
      @OliverSalzburg Sadly, it's not in standby now. Standby is great, and should be ON always. It's a good stuff. But now, for some reason, this ram gets used as "Active". (I'm using uTorrent to test the speeds, and under a fast transfer, it starts happening.)
  • Apache
    Apache almost 12 years
    The properties option is not avaliable for the Printer and File sharing. :) Anyway, it's turned off, the cache it is. Yet in Rammap, every single file are getting into the file list, and the Active memory just keeps growing and growing.
  • Apache
    Apache almost 12 years
    That's weird. I have set the working size MAXIMUM to 1 gigabyte, and it just makes it way through. It'll go much higher, it doesn't care about the value or limit. Why?
  • Gregory MOUSSAT
    Gregory MOUSSAT almost 12 years
    You have to be sure to monitor the right value. Use the cacheset utility for that.
  • Jan Schejbal
    Jan Schejbal over 11 years
    Please tell that to my Windows 7, which swapped out all programs just to stuff a video file into the cache while encoding it - a file that will be read exactly once - and crashed the entire box.
  • Jan Schejbal
    Jan Schejbal over 11 years
    This may depend on the LargeSystemCache option. For whatever reason, I had it set (probably back from the time where the RAM I had was more than sufficient for everything I did).
  • psusi
    psusi over 11 years
    @JanSchejbal, that's the setting I could no longer remember due to the fact that I gave up on Windows a few years ago. Normally the kernel tries to swap out pages from processes that have been idle for some time because that memory can be better put to use caching files for active processes. That setting makes it more aggressive at this.
  • BeowulfNode42
    BeowulfNode42 over 10 years
    @JanSchejbal the LargeSystemCache registry key is no longer used as of 2008r2 according to blogs.technet.com/b/askperf/archive/2008/02/01/…