From: Ryan Davis Date: 2009-06-15T02:30:58+09:00 Subject: Re: C extension: VALUEs being collected too early On Jun 13, 2009, at 21:39 , eden li wrote: > I'm writing a C extension which passes around structs that refer to > Ruby VALUEs. During the course of execution, these VALUEs are > assigned new Ruby strings, hashes or arrays (via the rb_{str,hash,ary) > _new functions) through a series of callbacks. The problem is that it > seems they're getting collected too early before I have a chance to > use the result. > > I tried a few things to keep these VALUEs around (including calling > rb_gc_mark directly on these objects), but the only thing that seems > to prevent this early collection is by disabling the GC while my code > is executing. See "3.3 Encapsulate C data into a Ruby object" in README.EXT in the ruby source distribution.