views:

1346

answers:

3

What tools are available to either completely clear, or selectively remove cached information about file and directory contents?

The application that I'm developing is a specialised compression utility, and is expected to do a lot of work reading and writing files that the operating system hasn't touched recently, and whose disk blocks are unlikely to be cached.

I wish to remove the variability I see in IO time when I repeat the task of profiling different strategies for doing the file processing work.

I'm primarily interested in solutions for Windows XP, as that is my main development machine, but I can also test using linux, and so am interested in answers for that environment too.

I tried SysInternals CacheSet, but clicking "Clear" doesn't result in a measurable increase (restoration to timing after a cold-boot) in the time to re-read files I've just read a few times.

+2  A: 

A quick googling gives theese options for Linux

Unmount and mount the partition holding the files

sync && echo 1 > /proc/sys/vm/drop_caches

John Nilsson
Thanks, that looks very useful, though I'd possibly want to echo 3 instead of 1. I'm primarily interested in Windows XP, which is why I hadn't found that in my googling.
Stephen Denne
Unfortunately the linux environment I could make use of this in, has kernel version 2.6.9. drop_caches was added in kernel 2.6.16
Stephen Denne
+1  A: 

I've found one technique (other than rebooting) that seems to work:

  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

It isn't selective though. Ideally I'd like to be able to clear the specific portions of memory being used for caching the disk blocks of files that I want to no longer be cached.

Stephen Denne
A: 

http://serverfault.com/questions/91804/how-to-clear-windows-disk-read-cache

mljack
Unfortunately, it hangs when pressing "Clear". My system is Win7 x64
skevar7