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

Vitaly Davidovich vitalyd at gmail.com
Wed Oct 21 18:32:37 EDT 2015


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> 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
> > 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20151021/ec6a09d0/attachment.html>


More information about the Concurrency-interest mailing list