Suggested fix for JDK-4724038 (Add unmap method to MappedByteBuffer)
David M. Lloyd
david.lloyd at redhat.com
Tue Sep 8 17:03:11 UTC 2015
On 09/08/2015 08:11 AM, Andrew Haley wrote:
> On 09/08/2015 12:37 PM, David M. Lloyd wrote:
>> Then you do the real unmap when
>> the buffer is GC'd (maybe via Cleaner). This is very akin to how file
>> descriptors are cleaned up, AFAICT.
> Indeed it is, and it's no better than the status quo. This is an attempt
> to do better.
Actually it *is* better, as it releases the mapping to the underlying
file, and does not require any resources (outside of the page table
itself and any associated kernel bookkeeping) to maintain a valid state
during the time window between user-driven unmap and automatic GC. The
underlying file can (for example) immediately relinquish reserved disk
storage or RAM at unmap time (the desired effect), rather than waiting
for GC to come around (status quo).
I believe that reclaiming the reserved address space is of much less
importance than freeing the backing resources (especially for 64-bit
systems), which is why I suggest this approach.
More information about the core-libs-dev