[concurrency-interest] Is Reference.reachabilityFence() needed in Reference constructor?

David M. Lloyd david.lloyd at redhat.com
Wed Oct 21 19:17:36 EDT 2015


In fact this exact scenario has been observed in OpenJDK as well, hence 
the reason for having reachabilityFence() in the first place.

On 10/21/2015 05:32 PM, Vitaly Davidovich wrote:
> This is also the case on the CLR, and it produces "interesting"
> scenarios such as finalizer running concurrent to an instance method:
> http://blogs.msdn.com/b/oldnewthing/archive/2010/08/10/10048149.aspx.
> In .NET, there's a GC.KeepAlive(obj) method to extend liveness manually
> for cases where it's needed.
>
>
> On Wed, Oct 21, 2015 at 6:04 PM, Aleksey Shipilev
> <aleksey.shipilev at oracle.com <mailto:aleksey.shipilev at oracle.com>> wrote:
>
>     No, they aren't. That's a common misconception.
>
>     https://docs.oracle.com/javase/specs/jls/se8/html/jls-12.html#jls-12.6.1:
>
>     "Optimizing transformations of a program can be designed that reduce the
>     number of objects that are reachable to be less than those which would
>     naively be considered reachable. For example, a Java compiler or code
>     generator may choose to set a variable or parameter that will no longer
>     be used to null to cause the storage for such an object to be
>     potentially reclaimable sooner."
>
>
>     Thanks,
>     -Aleksey
>
>     On 10/21/2015 11:29 PM, thurstonn wrote:
>     > But the referent arg is on the stack (since the constructor is)
>     > Aren't all variables on the stack strongly reachable?
>     >
>     >
>     >
>     > --
>     > View this message in context:http://jsr166-concurrency.10961.n7.nabble.com/Is-Reference-reachabilityFence-needed-in-Reference-constructor-tp12819p12824.html
>     > Sent from the JSR166 Concurrency mailing list archive at Nabble.com.
>     > _______________________________________________
>     > Concurrency-interest mailing list
>     >Concurrency-interest at cs.oswego.edu
>     <mailto:Concurrency-interest at cs.oswego.edu>
>     >http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>     >
>
>
>
>     _______________________________________________
>     Concurrency-interest mailing list
>     Concurrency-interest at cs.oswego.edu
>     <mailto:Concurrency-interest at cs.oswego.edu>
>     http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>

-- 
- DML


More information about the Concurrency-interest mailing list