6

Sometimes you know better than Windows what files will be re-used later. Suppose you have 8GB of memory, and you use the same 1GB file every hour in an I/O-bound application (which takes 1 second to finish if the file is cached, and 1 minute if not.) Now you process some other 16GB of data that are not going to be re-used. Naturally the frequently used 1GB file will be pushed out of the cache. It would be beneficial if one can tell Windows to keep that 1GB file in memory. (Better yet, it would be great if one can tell Windows not to cache those 16GB of data, but I'm not optimistic that this can be done.)

The situation is worse for files in network shares: Windows removes files form the cache even if there is free memory. If you immediately re-use a file, it will still be in the cache; but if you close the file and wait for 30 seconds, the cache is gone, and the system will need to re-fetch the file from the remote server. For me this is very noticeable because I'm on a 3 Mbps network link and I work with files that are about 10 MB in size.

The poor-man's way to keep a file in the cache would be to keep reading the file. Are there any better ways? Are you aware of any programs that do this?

(If this can be easily done under Linux, please let me know too.)

2 Answers 2

3

Two things comes to mind.

  1. Copy the file to a RamDisk before first use and move it back to file when you are done with it. (QSoft’s RamDisk for $12 was recommended here)
  2. Buy a fast SSD drive and see if that helps (enough)
2
  • So there's no way to tell Windows to keep some files in its disk cache, eg. the .Net framework? Jul 9, 2012 at 12:12
  • OverTheRainbow: No, there is not. How are these programs accessing these files? MapViewOfFile, or traditional ReadFile/WriteFile (ugh)? Aug 14, 2014 at 22:00
0

This is possible with certain types, for example dll:

Windows caches a set of dlls that are commonly used, these are the 'Known DLLs'. In order to keep a dll file cached it would just need to be part of that set.

2
  • OP is not asking about known DLLs
    – clhy
    Jan 5, 2016 at 17:56
  • 1
    Actually, the OP isn't specific about what type of file he’s talking about, although the references to “data”, network shares, and Linux seem to rule out the possibility that he is asking about DLLs.  (And now I’m going to have nightmares about a 1 GB DLL file.) Jan 5, 2016 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .