From: "Iñaki Baz Castillo" Date: 2012-05-31T23:07:05+09:00 Subject: Re: [C exten] The last question about rb_gc_register_address(): a case in which in works with dynamic memory 2012/5/30 Iñaki Baz Castillo : > So, could somebody confirm me that the above is a *correct* usage of > rb_gc_register_address()? As said before, in my tests it works (it > avoids GC). I've found an article which talks about this: http://metaeditor.sourceforge.net/embed/ But I don't agree when it says: "The rb_gc_register_address function is calling ALLOC every time and is thus very slow. Lucky us we have a faster alternative: keeping track of all our objects in an array (or hash). This reduces the number of allocations, which give us speed." I'm pretty sure that, when adding an object to an Array or Hash, Ruby MUST perform malloc/ALLOC, so no difference here. The article aslo says that: objects = rb_ary_new(); rb_gc_register_address(&objects); "What happens if GC runs between [objects = rb_ary_new()] and rb_gc_register_address(&objects); ? Or can this never happen? Yes, AFAIK this can happen, but only in special cases (TODO which cases?)." I really hope this is NOT possible. If not we are lost. This is, if I create a VALUE in C land it cannot be GC'd in next C function. Hope I'm right here. -- Iñaki Baz Castillo