From: Alex Fenton Date: 2007-10-29T00:05:04+09:00 Subject: Re: SWIG / Ruby GC issues M. Edward (Ed) Borasky wrote: > redroofgreentree wrote: >> I have this really nasty SWIG/ruby GC issue. (Namely objects are being >> freed when I don't want them to be freed). >> > > Well ... I guess I would start off by saying, "gdb is your friend". :) > But all SWIG does is generate wrapper/interface code between the Ruby > and the C or C++ code. Can you make this work without SWIG? SWIG does help with memory management,; there's an unusually helpful section on GC in the SWIG docs, which repays close reading http://www.swig.org/Doc1.3/Ruby.html#Ruby_nn57 You definitely need a debugger to identify what's getting prematurely destroyed, but once you have a stack trace which shows what method is being called on a deleted object, it's normally not hard to write a %markfunc to protect it alex