What is the fadvise / madvise equivalent on windows?

On UNIX, I can, for example, tell the OS that mapping will be needed in the future using posix_fadvise(POSIX_FADV_WILLNEED) . Then it will read the data if so.

How do I report that access is for Windows?

+10
memory-management unix portability winapi
Jul 29 '09 at 15:36
source share
3 answers

In fact, as Anders usually suggested, there is no such method in the memory management functions available in Windows 7 and earlier .

There are 2 different ways to do something like this:

  • Read data asynchronously with ReadFileEx . Then the data can still be in the file cache, if necessary later.
  • Open the stream hint file with the FILE_FLAG_SEQUENTIAL_SCAN CreateFile attribute. Readahead may be automatically executed.
+9
Dec 08 '09 at 17:19
source share

Starting with Windows 8, the PrefetchVirtualMemory function exists for this purpose.

+5
Sep 19 '13 at 17:49 on
source share

You can pass FILE_FLAG_RANDOM_ACCESS or FILE_FLAG_SEQUENTIAL_SCAN to CreateFile ()

+4
Jul 29 '09 at 16:58
source share



All Articles