Background:
I have an application which plays video files from disc. When I play these files the first time the file reading sometimes lags. However, the second time it is played there is never any lag, I suspect this is because the file is put into the windows file cache the first time it is played.
The requirements of my application is that it should be able to play any video at any time (the same video is almost never played twice, thus making the cache unnecessary), this makes the current problem quite critical.
In order to debug this problem I would need to disable windows xp file caching.
Question
Is there a way to disable windows xp file caching?
EDIT/More Info
Im using ffmpeg, and have no access to the actual file read calls. The problem can occur even if several other files have been played previously (warm up).
In general, you can’t just force
FILE_FLAG_NO_BUFFERING. It requires aligned buffers, and typically these aren’t provided. Besides, it’s the wrong thing. You don’t care whether Windows reads 32KB ahead.The only thing that you’d like Windows to do is discard file contents from cache after you’ve read them. The correct flag for that is
FILE_FLAG_SEQUENTIAL_SCAN. This hints Windows that you (probably) won’t seek back, so there is no reason to keep those bytes in cache.