From: "Mauricio Fernández" Date: 2003-03-01T18:37:45+09:00 Subject: Re: I'm stuck On Sat, Mar 01, 2003 at 04:26:49PM +0900, Friedrich Dominicus wrote: > ts writes: > > > >>>>> "F" == Friedrich Dominicus writes: > > > > F> Ok I understand that now, what do I have to do that it does not > > F> happen? > > > > Well in my case you need to write > > > > void tt() > > { > > char i; > > VALUE obj; > > > > obj = rb_str_new2("a string"); > > > > /* call some ruby functions which call the GC */ > > > > i = RSTRING(obj)->ptr[0]; > > } > I have another question related to this, aren't there any functions > provided to inform the GC that a particular object should not be > collected at the moment? As shown I do not know the ins/outs from If you hold a reference to it in the stack it won't be collected. If it's in a global variable, you can use void rb_gc_register_address(addr) VALUE *addr; void rb_gc_unregister_address(addr) VALUE *addr; > Ruby, but I have learned about dealing with a copying GC in Eiffel an > there some features are provided to exclude a particular object from > beein moved. There this function have names with freeze or frozen in > it. Is OBJ_FREEZE supposed to do something simular? Ruby's GC is mark & sweep, not copying, so objects are never moved. In Ruby frozen objects cannot be modified but they will be GCed if there's no reference to them. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Sex, Drugs & Linux Rules -- MaDsen Wikholm, mwikholm@at8.abo.fi