I am using the mmap
function on iOS in a drawing app. I have a file that uses mmap
and then I create a CGBitmapContext
from that memory. The user may perform many core graphics operations on this CGBitmapContext
with their finger, which will cause the memory to be updated constantly.
How often will this flush to the flash storage and is this a concern for wearing out the flash storage or for performance? I haven't noticed anything bad in my tests, but I am not familiar enough with mmap
to know for sure.
iOS is pretty smart about how often it flushes to disk. I have noticed that when I background the app, as long as I call msync
, i.e. msync(self.memoryMap, self.memoryMapLength, MS_SYNC);
it flushes properly.
While I use the app, even if there is a crash or sudden termination, usually all data is saved. If I kill my app while debugging, sometimes the last few changes are not saved, but usually everything is saved.
So my conclusion is that this is not a concern. iOS is not constantly writing to disk, it is writing to disk at smart intervals.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With