From: Robert Klemme Date: 2012-04-18T18:51:00+09:00 Subject: Re: C extensions: disable GC for a Ruby object and enable GC later for it On Mon, Apr 16, 2012 at 8:54 PM, Ammar Ali wrote: > On Mon, Apr 16, 2012 at 9:31 PM, Iņaki Baz Castillo wrote: >> I'm coding a Ruby C extension which usess Ruby objects (Proc objects, >> class instances...) asynchronously, which means that I need to tell CG >> not to try those objects until I use them so they can be GC'd. >> >> Could I know which two C functions should I use?: >> >> 1) a function for avoiding GC on a given Ruby object (VALUE). >> 2) a function to re-enable GC on a given Ruby object (VALUE). > > There are at least a couple of ways. One is to decalre these objects > as global variables, but that means they will live for the life of the > program (i.e. no GC until the end) > > rb_global_variable Wouldn't it also work to declare an Array as global variable or constant and place objects inside until they are no longer needed? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/