From: Tilman Sauerbeck Date: 2004-12-04T01:30:10+09:00 Subject: Re: GC run at end of script execution - order in which objects are claimed? ts [2004-12-03 17:21]: > >>>>> "T" == Tilman Sauerbeck writes: > > T> Is the order, in which the GC claims the objects at this point, defined > T> at all or does it claim them in undefined order? > > It's like the key for an hash : there is a defined order but you can't > predict it :-) Okay. > T> However, when I quit the application, the GC seems to break this policy. > > You must write your extension, in such a way that the child are freed before > the parent. Never expect that ruby will do this for you. I'm confused - I thought I'm telling Ruby in what order the objects should be freed by the way I'm calling rb_gc_mark(). If I cannot define the order in which the objects are freed by the rb_gc_mark() function calls, how else could I do that? I have a feeling there will be a lot of problems if I hack my extension so that it doesn't do anything in the object-free callback. I'd have to keep track of objects that Ruby thinks are freed but that still exist in C space... and free them at some point. Ugh. Please shed some more light on this. -- Regards, Tilman