How can I get read-ahead bytes?

Posted by Bruno Martinez on Stack Overflow See other posts from Stack Overflow or by Bruno Martinez
Published on 2010-04-28T19:20:02Z Indexed on 2010/04/28 19:57 UTC
Read the original article Hit count: 280

Operating systems read from disk more than what a program actually requests, because a program is likely to need nearby information in the future. In my application, when I fetch an item from disk, I would like to show an interval of information around the element. There's a trade off between how much information I request and show, and speed. However, since the OS already reads more than what I requested, accessing these bytes already in memory is free. What API can I use to find out what's in the OS caches?

Alternatively, I could use memory mapped files. In that case, the problem reduces to finding out whether a page is swapped to disk or not. Can this be done in any common OS?

© Stack Overflow or respective owner

Related posts about pagefile

Related posts about virtual-memory