Method to unmap MappedByteBuffer

Alan Bateman Alan.Bateman at oracle.com
Mon Jan 7 14:03:25 UTC 2019


On 07/01/2019 13:41, Luke Hutchison wrote:
> :
>
> Alternatively, I read in a few places that with the Windows file API, 
> if you open a file in shared mode, it can be deleted while reading 
> from it (no exclusive lock is held). Could the JDK Windows mmap code 
> be changed to open the file in shared mode? (I don't know what the 
> semantics would be if you deleted a currently-mmap'd file on Windows.)
>
FileChannel.open uses a sharing mode of FILE_SHARE_READ | 
FILE_SHARE_WRITE | FILE_SHARE_DELETE by default. This allows you to 
delete the file while it is open (the actual deletion will be deferred 
until everyone closes the file of course). Unfortunately this doesn't 
help when the file is also memory mapped, this is a Windows limitation 
that we have not been able to find a solution too.

-Alan.


More information about the nio-dev mailing list