From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-04-17T20:21:45+09:00 Subject: Re: tutorial on embedding ruby (review) On Wed, 16 Apr 2003 18:28:03 +0000, Steve Hart wrote: > > Thanks v much for reply. However, Mauricio (prev reply) says v > definitly gets GC'd whilst you say it may not - which is correct?. I don't know.. but I would think it gets destroyed by GC. OK I think I know where you are going. You want an Abstract Factory which you can create ruby insances through ? This reminds me of http://rubyxx.sourceforge.jp/index.en.html I have made some modifications for your code :-) class ObjNode { private: VALUE obj; public: ObjNode(string name, VALUE value) : name(name), value(value) { #ifdef USE_MARK } void Mark() { rb_gc_mark(obj); } #else rb_gc_register_address(&obj); } ~ObjNode() { rb_gc_unregister_address(&obj); } #endif }; Observe that there is a "USE_MARK" define.. I don't know enough about your situation, but this depends on where you hold the instance of MyCPBaseClass. (a) If you instantiate it from ruby then define USE_MARK. (b) If you instantiate it from c++ then UNdefine USE_MARK. You can see an example of the (a) situation if you look here: http://metaeditor.sourceforge.net/embed/mark.png This concept is not easy to grasp... but its about wheter your MyCPPBaseClass is memory managed from ruby(a) or cpp(b). Who is the parants-parent? (grand-parent) OK.. I will take a break now and have some breakfast :-) -- Simon Strandgaard