From: emilie3012@... (Steve Hart) Date: 2003-04-10T23:24:34+09:00 Subject: Re: tutorial on embedding ruby (review) Mauricio Fern�ndez wrote in message news:<20030410075956.GA25804@student.ei.uni-stuttgart.de>... > On Thu, Apr 10, 2003 at 11:42:27AM +0900, Steve Hart wrote: > > what happend if the GC runs between objects = rb_ary_new() and > > rb_gc_register_address(&objects); ? Or can this never happen. > > It could happen but Ruby's GC is conservative, which means that it will > scan the stack (where the variable objects lives) to find references to > objects. matz took care of it for you :-) > > -- > _ _ > | |__ __ _| |_ ___ _ __ ___ __ _ _ __ > | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ > | |_) | (_| | |_\__ \ | | | | | (_| | | | | > |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| > Running Debian GNU/Linux Sid (unstable) > batsman dot geo at yahoo dot com > > Never trust an operating system you don't have sources for. ;-) > -- Unknown source Yes, I've learnt a lot in the last 12 hours! I read some of the threads relating to GC and think I have a better understanding now. If the variable sits in the stack frame GC will pick it up automatically - great until it goes out of scope or, as in my case, get overwritten with another value (oops!). If the VALUE is stored elsewhere (C++ class, struct etc) then you need to let GC know via register/mark. Still, it took me nearly 2 days to elicit this info from this news group which maybe proves the point regarding a decent guide which could explain these subtleties (and I could still have got it wrong!)