From: Florian Frank Date: 2007-08-03T09:41:24+09:00 Subject: Re: finalizer not getting called Florian Frank wrote: > Another possibility is to use a binding, that doesn't Ahmmm. Let's continue here: ...contain the value, perhaps TOPLEVEL_BINDING and evaluate a string in this context: class A def initialize ObjectSpace.define_finalizer(self, eval('proc{|id| puts "finalizing #{id}"}', TOPLEVEL_BINDING)) end end def foo a = A.new end foo # don't taint the toplevel GC.start sleep(5) puts 'exiting' Like I said, it's not pretty to use finalizers in Ruby and you perhaps shouldn't. Using the yield pattern mentioned by Alex Young is perhaps a better solution to your problem. -- Florian Frank