MemoryMappedBuffer flushing

Florian Weimer fweimer at redhat.com
Tue Sep 30 12:13:00 UTC 2014


On 09/23/2014 05:28 PM, Bobrowski, Maciej wrote:
> Now, let’s think more in the case of MappedByteBuffer and IPC. Let’s
> assume I put 100 bytes on each call to put i.e. place 100 bytes in the
> memory mapped file in Process A. Given the above, do I have *any
> *guarantees, that the page synchronozation *will not * happen half way
> through my process writing to the page, so that the underlying file will
> reflect an update of 50 bytes only?

No, there are no such guarantees.  You'd have to use appropriate atomic 
instructions or POSIX shared mutexes, neither of which are currently 
supported for use with MemoryMappedBuffer by the JDK (but you could 
manipulate it as a direct buffer using JNI).

-- 
Florian Weimer / Red Hat Product Security


More information about the nio-dev mailing list