Heya guys, This one is bothering me as its evading my eye. I''m trying to set a callback on finalization of an object, ie: a finalizer set through a plugin to the model. Example In Plugin: def acts_as_goat class_eval do ObjectSpace.define_finalizer(self, lambda {self.conn.close} ) end end class UberGoat < ActiveRecord::Base acts_as_goat end Is this the correct way to set a finalizer or am I going about it the wrong way. I need to close a socket connection _after_ the model goes out of scope where GC usually happens. Do models get GC''d after a page is done loading? Thanks for any help. -- -- Adam Ballai <adam.ballai@integrumtech.com> Integrum Technologies, LLC Phone: +1 602 792 1270 x 104 Mobile: +1 602 373 3072 _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
* Adam Ballai (adam.ballai@integrumtech.com) [060220 14:30]:> Is this the correct way to set a finalizer or am I going about it the > wrong way. I need to close a socket connection _after_ the model goes > out of scope where GC usually happens. Do models get GC''d after a page > is done loading?Adam, Is it a question of timing, or getting a finalizer to fire at all? Generally, the garbage collector isn''t guaranteed to be called at any particular time, so getting deterministic finalizer behavior is somewhat difficult. There isn''t much call in Ruby for finalizers. Perhaps there''s another way to meet whatever constraints you have? Should this be sent to the main Rails or Ruby list(s)? Best, Rick -- http://www.rickbradley.com MUPRN: 218 | check for Create events random email haiku | have to check for Create or Split. | That ripple would be bad.