Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time Consumption of FlushViewOfFile (Windows) and msync(Linux)

Tags:

c++

linux

windows

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,

like image 250
Frank Avatar asked Oct 21 '25 05:10

Frank


1 Answers

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.

like image 121
David Heffernan Avatar answered Oct 23 '25 20:10

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!