On Sat, Jun 29, 2013 at 8:41 AM, Jim - FooBar(); <jimpil1...@gmail.com>wrote:

>  Hi all,
>
> I just finished watching this (
> http://www.infoq.com/presentations/jvm-tuning?utm_source=infoq&utm_medium=videos_homepage&utm_campaign=videos_row1
> )
> and I'm not sure I understood everything and specifically what he said
> about finalizers. I noticed that Stuart Sierra  (yes, I recognise his
> voice!) asked a question about this but the answer he got was pretty vague
> in my opinion...
>
> First of all what does he mean by "finalizers"? Does the mean the
> .finalize() method on java.lang.Object, the try/finally idiom or custom
> "cleaning-up" methods?
> Secondly, he said they are not good practice because they require 2 GC
> cycles....
>

Then he meant the .finalize() method.

but why do they require 2 GC cycles?
>

Because the first time the object is found to be unreferenced, the
finalizer is scheduled to run, and the object must be kept alive as the
finalizer presumably uses it in some way (e.g. a stream object finalizer
closes a file descriptor held by the stream object in a field somewhere).
Then a second GC cycle needs to catch the finalized object unreferenced and
actually collect it. The finalizer could, in theory, "resurrect" an object
so eagerly composting it as soon as the finalizer exits isn't an option.

>  ps: I seriously hope he didn't mean the try/finally idiom because clojure
> makes significant use of it.... :)
>

They didn't. :)

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to