RFR: 8350905: Releasing a WeakHandle's referent may extend its lifetime

William Kemper wkemper at openjdk.org
Tue Mar 11 19:41:04 UTC 2025


On Thu, 6 Mar 2025 18:57:18 GMT, William Kemper <wkemper at openjdk.org> wrote:

> When weak handles are cleared, the `nullptr` is stored with the `ON_PHANTOM_OOP_REF` decorator. For concurrent collectors using a SATB barrier, this may cause the referent to be enqueued and marked when it would be otherwise unreachable. The problem is especially acute for Shenandoah's generational mode, in which a young region holding the otherwise unreachable referent, may become trash after the referent is enqueued for old marking. We are proposing that native weak references are cleared with an additional `AS_NO_KEEPALIVE` decorator. This is similar to what was done for j.l.r.WeakReference in [JDK-8240696](https://bugs.openjdk.org/browse/JDK-8240696).
> 
> # Testing
> 
> GHA, `hotspot_gc_shenandoah`. Additionally, for G1, ZGC, and Shenandoah we've run Extremem, Dacapo, SpecJVM2008, SpecJBB2015, Heapothesys and Diluvian. All executions completed without errors.

Withdrawing this PR. We'll do this in the Shenandoah barrier.

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

PR Comment: https://git.openjdk.org/jdk/pull/23935#issuecomment-2715505017


More information about the hotspot-gc-dev mailing list