Sean O'Dell <sean / celsoft.com> [2004-07-30 15:42]: > On Thursday 29 July 2004 13:11, Tilman Sauerbeck wrote: > > > > I know I can work around this by using rb_global_variable() to tell the > > GC not to claim the object, but this kinda sucks since the object will > > never be freed :( > > > > So, my question is: how do I prevent the Result object from being > > claimed by the GC without using rb_global_variable's? > > If this object is a VALUE variable in your C code, you should declare it this > way: > > volatile VALUE result = Qnil; > > Adding volatile allows the GC to see the object on the C stack. This means > that so long as your C code holds it in that variable, it will never go away. Okay, but that wouldn't really be different from using rb_global_variable() and rb_gc_unregister_address(), right? I just noticed my last question was badly worded :/ I _do_ want the GC to claim the object eventually, but not if the callback might still be called. -- Regards, Tilman