[concurrency-interest] DirectByteBuffers and reachabilityFence

Vitaly Davidovich vitalyd at gmail.com
Wed Dec 9 15:36:40 EST 2015


>
> Yes, you do increment the counter at each operation.  There has to be
> a use of the counter in the finalizer to keep it alive.


Right, that's what I thought would need to happen, but then you made it
sound like only finalizer actually does something.  So here you have a
possible performance degradation ...


> Thinking about it some more though, even this may not be enough in the
> presence
> of some very aggressive optimizations because there is no
> happens-before relationship between the methods and the finalizer.


Yup, and that's why I said I doubt this even works.

Ummm, I don't understand this.


Before your clarification that counter is updated at each use, I was just
saying that if counter is only used inside finalizer then you may as well
just put reachabilityFence(this) in there.  In other words, if you had some
reason to believe that simply using some field of the object inside the
finalizer was sufficient, then rF(this) is just as good.  This is, of
course, incorrect but that's what I meant.


On Wed, Dec 9, 2015 at 2:51 PM, Andrew Haley <aph at redhat.com> wrote:

> On 12/09/2015 07:20 PM, Vitaly Davidovich wrote:
> > I don't see how this extends the lifetime of the object unless, at
> minimum,
> > you increment the counter at each operation where you want to extend the
> > lifetime.
>
> Yes, you do increment the counter at each operation.  There has to be
> a use of the counter in the finalizer to keep it alive.  Thinking
> about it some more though, even this may not be enough in the presence
> of some very aggressive optimizations because there is no
> happens-before relationship between the methods and the finalizer.
>
> > And at this point, you may as well just stick
> > reachabilityFence(this) inside the finalizer then.
>
> Ummm, I don't understand this.
>
> Andrew.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20151209/a5cc68b5/attachment-0001.html>


More information about the Concurrency-interest mailing list