JDK-6990438 : (ref) Soft reference could consider strong if GC decides not to clear
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2010-10-07
  • Updated: 2016-02-02
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
The scenario is depicted in this object graph:
   Root -> .... -> SR -> A -> ... -> WR -> B -> ....

where SR is a SoftReference that points to object A and WR is a WeakReference
that points to object B.  Both A and B are not reachable.

As specified in the java.lang.ref spec, B is softly reachable as
(1) B is not strongly reachable, and
(2) B can be reached by traversing a soft reference (SR)

B is not weakly-reachable since it is softly reachable as described 
above.

When GC decides not to clear the soft reference, it would be intuitive
to consider that as a strong reference for the rest of the GC operation
and therefore clear WR and reclaim B.  The behavior conforming to
the current specification doesn't clear WR (as B is not weakly reachable).

This RFE is to request an enhancement to the java.lang.ref API to
support this new behavior.

Comments
EVALUATION This request sounds reasonable and we need to investigate how this can be done in a compatible way.
07-10-2010