RFR: 8324972: (bf) Make DirectByteBuffer.Deallocator idempotent [v4]

Alan Bateman alanb at openjdk.org
Fri Feb 9 11:27:53 UTC 2024


On Thu, 8 Feb 2024 10:58:05 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> This PR proposes to make deallocators and unmappers for memory regions idempotent. This is to prevent (likely very rare) duplicate invocations. 
>> 
>> There are no unit tests but it should be noted that the idempotent behavior (now correct) is similar to the  intended behavior before cf74b8c2a32f33019a13ce80b6667da502cc6722 but where idempotency was not guaranteed in a multi-threaded environment.
>> 
>> Passes tier1, 2, and 3 tests.
>
> Per Minborg has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Use existing UNSAFE static variable
>  - Remove unused import

Just to add that I don't think Unsafe.invokeCleaner racing with the Cleaner is an issue. The clean method is specified to specified to invoke the cleaning action at most once, and the PhamtomCleanable.clean method appears to be correct.

I wonder if @msheppar could re-phrase JDK-8324972 to more clearly explain why there is perceived issue issue. Note that I'm not opposed to making the cleaner action idempotent, I'm just trying to see how it possible for it to run more than once.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17647#issuecomment-1935753766


More information about the nio-dev mailing list