[Ironruby-core] Adding a finalizer to a ruby object

Ivan Porto Carrero ivan at flanders.co.nz
Fri Jan 8 09:23:36 EST 2010


Hi

How do I add a finalizer to a ruby object?

I've tried using ObjectSpace and define_finalizer.
But the proc never got executed when I called ObjectSpace.garbage_collect
Calling System::GC.collect had the same outcome

and implementing a Finalize method doesn't seem to have any effect either

class MyClass

  def Finalize
    puts "in Finalize"
  end

  def finalize
    puts "in lower finalize"
  end

end

MyClass.new
System::GC.collect System::GC.max_generation,
System::GCCollectionMode.forced
#ObjectSpace.garbage_collect

Thanks
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Google Wave: portocarrero.ivan at googlewave.com
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100108/9dc798ea/attachment.html>


More information about the Ironruby-core mailing list