From: Tridib Bandopadhyay Date: 2012-01-10T09:53:30+09:00 Subject: Re: Free an Object I have some questions on the Code > class DestroyObject > def initialize > # Adds a proc as finalizer, this will be called after the object was > destroyed > # Source: > http://www.ruby-doc.org/core-1.9.3/ObjectSpace.html#method-c-define_finalizer > ObjectSpace.define_finalizer(self, > self.class.method(:finalize).to_proc) > end What does self and self.class.method referring to? > > # This should be a class method, not an instance method > # For reason, > http://www.mikeperham.com/2010/02/24/the-trouble-with-ruby-finalizers/ > def self.finalize(id) > puts "Object #{id} dying at #{Time.now}" > end > end > > DestroyObject.new > > # Initiates garbage collection > # Source: > http://www.ruby-doc.org/core-1.9.3/ObjectSpace.html#method-c-garbage_collect > ObjectSpace.garbage_collect And which object is getting deleted? And who is deleting it? My debugged free method or is it asking for Garbage Collect? Thank You Tridib -- Posted via http://www.ruby-forum.com/.