From: "Iñaki Baz Castillo" Date: 2011-02-09T08:18:36+09:00 Subject: Re: C extension: How to check if a VALUE is still alive (not being GC'ed)? 2011/2/8 Eric Hodel : >> Yes, that's work: the resolver object contains a hash attribute in >> which queries are stored until completed. > > Use a ruby hash and supply mark and GC callbacks to Data_Wrap_Struct so the GC will keep track of it. Thanks, but I don't understand why I must use mark callback: - My class uses Data_Wrap_Struct containing a xxx_free function to free the C structure when the object is GC'ed. - An instance of my class contains an @hash attribute (which is set empty in initialize method). - Such @hash is populted with some normal Ruby objects during runtime. Nothing special here. - So when my instance is GC'ed, at some point Ruby will GC the @hash attribute and also the objects it contains. Then... why do I need a mark callback? Maybe I miss something, however Itested my code under high load and doesn't seem to leak. Thanks a lot. -- Iñaki Baz Castillo