Provide API to explicitly unmap MappedByteBuffer?

Paul Sandoz paul.sandoz at oracle.com
Tue Mar 20 16:19:16 UTC 2018


Also, we may have another swing at this problem in Project Panama, where memory regions are more explicitly managed via scopes. However, there will still be similar safety and performance challenges.

Paul.

> On Mar 20, 2018, at 7:54 AM, Langer, Christoph <christoph.langer at sap.com> wrote:
> 
> Thanks Alan,
>  
> I can see the history in bug https://bugs.openjdk.java.net/browse/JDK-4724038 <https://bugs.openjdk.java.net/browse/JDK-4724038>...
>  
> Best regards
> Christoph
>  
>  
>   <>
> From: Alan Bateman [mailto:Alan.Bateman at oracle.com] 
> Sent: Dienstag, 20. März 2018 14:59
> To: Langer, Christoph <christoph.langer at sap.com>; nio-dev at openjdk.java.net
> Subject: Re: Provide API to explicitly unmap MappedByteBuffer?
>  
> On 20/03/2018 10:39, Langer, Christoph wrote:
> 
> Hi,
>  
> I was just handling a customer issue where Java code tried to delete a file on Windows which was mapped into memory vial FileChannel.map() before. It took me a little while to understand the issue but obviously the problem was that Windows still kept a delete lock on the file as long as the ByteBuffer was still mapped. This behavior is also documented cleanly:https://download.java.net/java/jdk10/docs/api/java/nio/MappedByteBuffer.html <https://download.java.net/java/jdk10/docs/api/java/nio/MappedByteBuffer.html>.
>  
> So far so good, I just started wondering why there isn’t an API to force unmapping (cleanup) on a MappedByteBuffer? The app that opens the mapping simply reads a properties file at this place and I guess they should be able to change this place to use standard io easily and without observable performance problems. However, if they had a way to explicitly unmap the MappedByteBuffer it would also help.
>  
> Was this topic already discussed? Is there a hard reason why explicit cleanup should not be offered? I guess people using MappedByteBuffers should know anyway what they are doing…
>  
> This has been discussed many times, it's a really hard problem that many smart people have spend time on.
> 
> Andrew Haley may be able to say more about this. He has (or had) a proposal on this but it involved deep changes in the VM. I don't know he has prototyped it yet to see how feasible it is.
> 
> -Alan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20180320/771fb041/attachment.html>


More information about the nio-dev mailing list