From: "Sean O'Dell" Date: 2003-09-04T03:43:21+09:00 Subject: Ruby GC eating my VALUE on the stack I thought I had read everything I needed about the Ruby GC, but something just popped up that took me by surprise. I am allocating a structure using malloc in QuiXML (in C), then wrapping it in Data_Wrap_Struct, providing mark and free functions. Data_Wrap_Struct returns a VALUE, which is stored in a variable on the stack. I never leave this function; I call other functions and pass the pointer to the structure around, but the variable holding the VALUE stays on the stack the entire time. I am stress-testing QuiXML, so I am deliberately dogging memory to get the GC to invoke naturally. At some point, a rb_str_new() call causes the GC to kick in because right then, the free callback for my structure gets called. Now, from what I understand, since the VALUE associated with the structure is still on the stack, the GC was supposed to see it and automatically mark it so my structure won't get freed prematurely. So why did it not get marked? Why was free called? Sean O'Dell