Method to unmap MappedByteBuffer
Luke Hutchison
luke.hutch at gmail.com
Sun Jan 13 17:02:13 UTC 2019
On Mon, Jan 7, 2019, 7:03 AM Alan Bateman <Alan.Bateman at oracle.com wrote:
> 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.
>
I asked about this on StackOverflow, and one of the responses indicated
that POSIX file deletion semantics have been added to recent builds of
Windows 10, via FILE_DISPOSITION_POSIX_SEMANTICS :
https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddk/ns-ntddk-_file_disposition_information_ex
This allows the file to be "deleted" while open by causing it to be hidden
in the directory until it is closed (also allowing another file of the same
name to be created in its place -- so the file is presumably also renamed).
It looks like this is a solution to the file deletion part of this
long-time problem, for new Windows builds at least. Can this be added to
NIO for mmap'd files, if the Windows version supports it? (Actually it
would be great to make POSIX semantics the default for all file operations
in Java on Windows, but mmap is the most problematic case right now.)
Discussion here:
https://stackoverflow.com/questions/54138684/memory-mapping-a-file-in-windows-with-share-attribute-so-file-is-not-locked-aga/54144481
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190113/56e1370a/attachment.html>
More information about the nio-dev
mailing list