From: Paul Brannan Date: 2002-08-10T01:33:35+09:00 Subject: Re: Are All C Destructors Guaranteed to Be Called? On Fri, Aug 09, 2002 at 11:24:27PM +0900, William Djaja Tjokroaminata wrote: > Are all C destructors, i.e., the "free" function that is specified in > Data_Make_Struct (VALUE, c-type, mark, "free", c-type*), guaranteed to be > called when the Ruby script/process exits? They get called when the object needs to be destroyed. I think all objects are supposed to be destroyed at exit. > I put "printf" on all the "free" functions, and one of them did not get > called. Is it a sign that something is still not clean? How about > circular reference (I think I have one in my code)? Will circular > reference cause the free function not called at the end of the > script/process? 1) Can you reproduce this behavior in a small test case? 2) Ruby uses mark/sweep instead of reference counting, so circular references won't cause an object to not get GC'd. What *can* happen is that an object doesn't get destroyed because someone is keeping a reference who is not supposed to be keeping a reference, but both objects should be destroyed at exit. Paul