How to clear Windows disk read cache?

For performance testing I need to clear Windows' disk read cache. I tried googling but I couldn't find anything other than rebooting or other manual stuff. Before I give in and do that, I'd like to know if anyone knows of a way to clear Windows disk read cache. I'm testing on Windows 7, but I'm also interested in Windows XP solutions.


Alternatively fill the cache with data that you know won't be used in the test, then run the test.


I'd asked the same question on Stack Overflow

https://stackoverflow.com/questions/478340/clear-file-cache-to-repeat-performance-testing

I was using Win XP, but the best solution I came up with was:

  1. Run a few copies of MemAlloc
  2. With each one, allocate large chunks of memory a few times
  3. Use Process Explorer to observe the System Cache size reducing to very low levels
  4. Quit the MemAlloc programs

For a much better view of the Windows XP Filesystem Cache - try ATM by Tim Murgent - it allows you to see both the filesystem cache Working Set size and Standby List size in a more detailed and accurate view. For Windows XP - you need the old version 1 of ATM which is available for download here since V2 and V3 require Server 2003,Vista, or higher.

You will observe that although Cacheset will reduce the "Cache WS Min" - the actual data still continues to exist in the form of Standby lists from where it can be used until it has been replaced with something else. To then replace it with something else use a tool such as MemAlloc, flushmem by Chad Austin, or Consume.exe from the Windows Server 2003 Resource Kit Tools.


I've used RAMMap. It has possibility to free memory of few types of allocations.

The contents of the file cache can be observed in the "File Summary" tab and selecting "Empty Standby List" from the "Empty" menu should clear this cache.