RFR: 8071507: (ref) Clear phantom reference as soft and weak references do

Mandy Chung mandy.chung at oracle.com
Wed Dec 2 18:58:46 UTC 2015


Kim, 

Thanks for sending this out.  I like the 1-line fix in hotspot - simple and sweet.

Mandy

> On Dec 2, 2015, at 10:37 AM, Kim Barrett <kim.barrett at oracle.com> wrote:
> 
> Please review this change to PhantomReference processing, changing the
> GC-based notification to automatically clear the referent.
> 
> This change provides performance benefits by eliminating the work
> involved in keeping the otherwise inaccessible referent objects alive,
> as required by the existing specification. This not only immediately
> removes some work, but may enable further performance improvements.
> It also allows the referent objects to be immediately reclaimed in
> the GC cycle in which they were determined to be inaccessible, rather
> than lingering as a form of floating garbage until the application
> deals with the notified reference.
> 
> This change results in a behavioral change to application code, as
> demonstrated by the associated test.  Under the old specification, a
> reference R with referent X may be kept alive because it is referenced
> by an otherwise inaccessible referent Y of phantom reference P.  This
> will result in X being treated as strongly referenced and prevent R
> from being notified, even if R is a phantom reference and X has become
> inaccessible to the application.  With this change, Y is reclaimed
> when it becomes inaccessible and P is notified, and no longer prevents
> X from itself becoming a candidate for reclaimation once it is no
> longer accessible to the application.  While this is a change in
> behavior, it seems unlikely to affect applications negatively.
> 
> CR:
> https://bugs.openjdk.java.net/browse/JDK-8071507
> 
> Webrevs:
> http://cr.openjdk.java.net/~kbarrett/8071507/jdk.05/
> http://cr.openjdk.java.net/~kbarrett/8071507/hotspot.05/
> 
> Testing:
> jprt, aurora ad hoc (defaults, GC/Runtime nightly, JCK)
> 




More information about the core-libs-dev mailing list