RFR: 8344332: (bf) Migrate DirectByteBuffer to use java.lang.ref.Cleaner [v13]

Brent Christian bchristi at openjdk.org
Tue Mar 4 23:16:13 UTC 2025


On Sun, 23 Feb 2025 10:20:23 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> I've made a prototype that adds Cleaner.waitForCleaning() and changes Bits.reserveMemory() to use it.
> 
> https://github.com/openjdk/jdk/compare/master...kimbarrett:openjdk-jdk:wait-for-cleaning?expand=1

These caught my eye during my read-through:

- The main `CleanerImpl.run()` loop is changed to call `queue.poll()` in place of (blocking) `queue.remove(timeout)`. Could this make this a busier wait loop? 
- My impression is that it does more locking.

I wonder how these together could affect performance of less specialized Cleaner usage cases (where objects are not being enqueued very often).

I'm therefore inclined for changes along these lines to be limited to a DirectByteBuffer-specific mechanism, as you suggested in your point (2).

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

PR Comment: https://git.openjdk.org/jdk/pull/22165#issuecomment-2699207286


More information about the core-libs-dev mailing list