Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • @Ben: Wait, why wouldn't the memory-mapped file respect the flag? Commented Mar 10, 2011 at 17:44
  • @Mehrdad: How could it? MapViewOfFile maps pages from the file cache into your process memory space using the MMU. Commented Mar 10, 2011 at 17:49
  • @Ben: I had no idea how it worked, but I imagined that it caused a page fault whenever a page was accessed, so the kernel could take control and fill the page with the data -- so there didn't actually have to be any caching. Commented Mar 10, 2011 at 17:51
  • You should also use FILE_FLAG_SEQUENTIAL_SCAN for large sequential reads. Commented Mar 10, 2011 at 17:53
  • 1
    @Mehrdad: It only does that the first time a page is accessed. Re-reading each page 4000 times would be crazy. And it's the cache manager which fills that page with data and decides when to free it... this is how memory-mapped files stay consistent between processes, because the same physical page is mapped by the cache manager into multiple processes. Your process doesn't own the memory. Commented Mar 10, 2011 at 17:56