Suggested fix for JDK-4724038 (Add unmap method to MappedByteBuffer)
aph at redhat.com
Tue Sep 8 13:10:20 UTC 2015
On 09/08/2015 12:37 PM, David M. Lloyd wrote:
> On 09/08/2015 04:30 AM, Andrew Haley wrote:
>> On 09/08/2015 09:58 AM, Paul Sandoz wrote:
>> However, I think that some cleverness in HotSpot could make that cost
>> go away. For example, we could associate with every
>> MappedByteBufferForwardingObject a protection page in memory. When
>> the forwarding object is unmapped that page is write-protected. Every
>> access to the mapped file is preceded by a write to the page; there
>> don't have to be any memory fence instructions. The protection page
>> would stay until the forwarding object was unmapped.
Sorry, I meant "until the forwarding object was collected".
> If you're already doing this, why not skip the level of indirection and
> mprotect the entire mapped region to PROT_NONE when the user unmaps?
Because one page has to hang around until the forwarding object is
garbage collected. The entire mapping doesn't.
More information about the core-libs-dev