I use memory mapped files to have read / write access to a large number of image files (~ 10000 x 16 MB) under Windows 7 64 bit. My goals:
Therefore, I use memory mapped files to access files. Caching works well, but the OS does not clear dirty pages until I almost got out of physical memory. Because of this, the allocation and writing to new files occurs rather slowly after the physical memory is full.
One solution would be to use FlushViewOfFiles() regularly, but this function does not return until data is written to disk.
Is there a way to clear file association asynchronously? The only solution I found was again Unmap() and MapViewOfFile() , but using this approach, I cannot be sure to get the same data pointer again. Can anyone suggest a better approach?
Edit: After reading the WINAPI documentation several times, I found a suitable solution for my problem:
Calling VirtualUnlock() on a memory range that is not locked results in the loss of dirty pages.
c ++ memory-mapped-files
user1511305
source share