What is fadvise/madvise equivalent on windows?

亡梦爱人 提交于 2019-11-28 11:10:28
Steve Schnepp

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

2 different ways exists to do something similar :

  • Read the data asynchronously with ReadFileEx. The data might then still be in the file cache when needed later.
  • Open the file with a streaming hint with the FILE_FLAG_SEQUENTIAL_SCAN attribute of CreateFile. Readahead would then perhaps be automatically done.

Beginning with Windows 8, there is the PrefetchVirtualMemory function for this purpose.

You can pass FILE_FLAG_RANDOM_ACCESS or FILE_FLAG_SEQUENTIAL_SCAN to CreateFile()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!