From: matz@... (Yukihiro Matsumoto) Date: 2001-12-29T01:15:05+09:00 Subject: [ruby-talk:29539] Re: GC and values in extensions Hi, In message "[ruby-talk:29532] Re: GC and values in extensions" on 01/12/28, Paul Brannan writes: | VALUE foo(VALUE self) { | VALUE x = rb_str_new2("foo"); | long y = (long)x; /* Assume x and y now have the same bit pattern */ | x = Qnil; | ... | return Qnil; | } | |then the newly allocated string will not be freed until foo returns? It won't. |Or |if I happen to store an integer that happens to look like a pointer to |the heap, then it is possible that some object that has no more |references may not actually get garbage-collected? They may not. |So there is no way |to depend on objects being garbage-collected, even if there are no more |references? No. That is what "conservative" means. |This also sounds a little inefficient to me (though it makes things |convenient for extension writers). Is it? It's pretty efficient. I've read the survey that misdetermination was less than 5% on a Lisp implementation using conservative GC. And from my brief experimental result, it happens even less in Ruby (virtually zero). I think you can ignore accidental misdetermination (except aritificial ones). matz.