Hi matz, a long time ago I remember you have teached me the usage of ObjectSpace._id2ref within finalizer. Perhaps you remember, it had to do with my filelock module? The message was from: Mon, 14 Dec 1998 12:37:39 +0900 with Subject: Re: Next trial: filelock.rb Here you had proposed to me: > So, you can get the object reference in finalization routine. > > def LockedFile.cleanup() > lambda do |id| > obj = ObjectSpace::_id2ref(id) > ... > end > end > > But, DO NOT EXPORT the object reference out of finalizer. It will > cause serious problem in collecting garbages. Now I want to implement a finalization module as a look-what's-worth attempt. Here I want to use exactly this trick. In detail I want to do: : Finalizer = proc do |id| if FinalizeClients.key? id ObjectSpace::_id2ref(id).send(:finalize) FinalizeClients.delete(id) end end : Up to Ruby-1.2 it should have worked, here the code of _id2ref has contained a piece of: : if (RANY(ptr)->as.free.flag == 0) { IndexError("0x%x is recycled object", ptr); } : But since Ruby-1.3.x the code was changed to: : if (BUILTIN_TYPE(ptr) == 0) { rb_raise(rb_eIndexError, "0x%x is recycled object", ptr); } : The changelog say: Wed Jan 6 02:42:08 1999 Yukihiro Matsumoto <matz / netlab.co.jp> : * gc.c (id2ref): modified to support performance patch. : Now this trick would not any longer work. If I try to use _if2ref as intended in my example above, an IndexError would be thrown. My question now: Is it possible to return to the old behavior? What i try to do in deatail is, that every instance could announce itself to the finalizer that would call the instance's 'finalize' method during finalization. But I need that _id2ref trick therefore. Ciao, \cle -- Clemens Hintze mailto: c.hintze / gmx.net