Time Consumption of FlushViewOfFile (Windows) and msync(Linux)-Collection of common programming errors
Good morning,
We are interested in the time consumption of FlushViewOfFile
and msync
. Quoting the UnmapViewOfFile
documentation:
To minimize the risk of data loss in the event of a power failure or a system crash, applications should explicitly flush modified pages using the
FlushViewOfFile
function.
Are FlushViewOfFile()
and msync()
expensive operations? The reason we are asking is that in our application, we may not need to minimize the risk of data loss in the event of a system crash.
Thank you,
-
They are expensive in the sense that they will move the cached file from memory to disk. Generally you use memory mapped files to avoid doing that! The normal strategy is to flush as infrequently as your program requirements allow.