From: Thomas Sondergaard Date: 2003-09-12T07:14:34+09:00 Subject: Re: GC - PLEASE set me straight > Hmm ... I'm confused about that statement. Well that wont do.. > If the VALUE is a member of a class, then it's probably NOT on the > stack, so volatile won't help you there. In this case, just use > rb_gc_register_address/rb_gc_unregister_address in your > constructor/destructor methods for your C++ class. 1) I am using rb_gc_register/unregister in my C++ wrapper. 2) I have now added the volatile keyword in all the functions where I use an automatic variable. Here's the relevant bit of the C++ wrapper: public __gc class Object : public DynamicLanguageSupport::IObject { public: explicit Object(VALUE handle) { _handle = ALLOC(VALUE); *_handle = handle; rb_gc_register_address(_handle); } ~Object() { rb_gc_unregister_address(_handle); free(_handle); } // stuff for invoking ruby methods from .net removed private: VALUE __nogc *_handle; }; Does it look reasonable? Cheers, Thomas