From: Rick DeNatale on
On Mon, Jul 5, 2010 at 12:05 PM, Roger Pack <rogerpack2005(a)gmail.com> wrote:
>> ObjectSpace.each_object(Test) { |o| puts o.inspect }
>> # => #<Inner:0x40b4470>
>>      #<Outer:0x40b4ff8 @inner=nil>
>>
>> I'm using ruby 1.8.7p249, but I have the same results with 1.9.1p378.
>> I'm on windoze (yeah, I know...). The problem does not appear on my Mac
>> (Inner is gone after GC). Any idea about this, a workaround? I need to
>> free OLE automation objects, that's why...
>
> Yeah get the same thing here.  It's the nature of conservative GC.
> I did a little writeup of it here:
>
> http://en.wikibooks.org/wiki/Ruby_Programming/Reference/Objects/GC#Conservative
>

That write up is a bit bogus I'm afraid.

1) The MRI GC is NOT conservative, it guards calls to gc_mark and it's
ilk by using the C function is_pointer_to_heap, since it marks objects
by setting bits in the object's header (the first word pointed to by a
potential object reference) marking a non-object by mistake would lead
to seriously hard to debug problems.

2) Although a conservative GC, if Ruby actually used it, could cause
objects to live past the point that could no longer really be reached,
many garbage collectors have the property that there is no guarantee
that unreachable objects are collected as soon as possible, only that
objects will NOT be collected as log as they are alive.



--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

From: Roger Pack on
Rick Denatale wrote:
> On Mon, Jul 5, 2010 at 12:05 PM, Roger Pack <rogerpack2005(a)gmail.com>

> That write up is a bit bogus I'm afraid.
>
> 1) The MRI GC is NOT conservative, it guards calls to gc_mark and it's
> ilk by using the C function is_pointer_to_heap, since it marks objects
> by setting bits in the object's header (the first word pointed to by a
> potential object reference) marking a non-object by mistake would lead
> to seriously hard to debug problems.

Hmm. Perhaps our definitions of conservative differ? To me
conservative means that it doesn't necessarily collect objects without
references...


> 2) Although a conservative GC, if Ruby actually used it, could cause
> objects to live past the point that could no longer really be reached,
> many garbage collectors have the property that there is no guarantee
> that unreachable objects are collected as soon as possible, only that
> objects will NOT be collected as log as they are alive.

True, but not MRI that I'm aware, except objects with finalizers I
suppose.
Oh feel free to change the content on that wiki page nothing sacred
there.

-r
--
Posted via http://www.ruby-forum.com/.

From: Thierry Lambert on
I keep thinking there is something to dig in this, but unfortunately I
will have no time to do it. Also, after re-checking, contrary to what I
posted first, I have the same problem on Mac: in between, I upgraded my
Mac ruby from 186 to 187...
Thanks anyway for the feedback.
Cheers
-- Thierry
--
Posted via http://www.ruby-forum.com/.