dev@grizzly.java.net

Re: Grizzly's 2.0 Slab.finalize() ?

From: Ken Cavanaugh <Ken.Cavanaugh_at_Sun.COM>
Date: Thu, 12 Feb 2009 17:17:43 -0800

Jacob Kessler wrote:
> For a description of what happens to finalizable objects (and a bit
> about why using them isn't such a good idea), take a look at
>
> http://java.sun.com/developer/technicalArticles/javase/finalization/
>
> Another potential problem is that since the finalization queue is
> processed in a single thread (I think...), if you have high churn of
> finalizable objects you can get OOM errors as the queue backs up.
>
I knew finalization was problematic, but I didn't realize it was
completely broken!
As Alexey correctly observed earlier in this thread, all that
Slab.finalize does is
track the amount of space reclaimed, which itself is only used when
there is an
error in the Slab constructor. I may have added this originally because
I was
having problems in my test with running out of memory. I was adding
this only
to see if Slab were being GCed. But if it turns out that adding a
finalize method
slow down the reclamation of the Slabs, this is just making any such
problems worse.

Best idea is simply to remove the finalize method. As Charlie
mentioned, I think we could
just use a ReferenceQueue so that we can track how fast Slabs get reclaimed.

Thanks,

Ken.