From: Robert Klemme Date: 2003-12-08T22:57:09+09:00 Subject: Re: WeakRef and Object#hash "Yukihiro Matsumoto" schrieb im Newsbeitrag news:1070890833.524202.5797.nullmailer@picachu.netlab.jp... > Hi, > > In message "Re: WeakRef and Object#hash" > on 03/12/08, "Robert Klemme" writes: > > |> As you can see, I'm not even adding methods, and it causes the weak > |> reference to not be recycled by the garbage collector. > | > |I had similar experiences about references not beeing cleared. Maybe > |someone with more insight (Matz?) should comment on this. Maybe only an > |instance's type is checked against WeakRef and not if it's a subtype of > |that. > > The weakly referenced object is also considered as referenced from C > stack region. It's due to Ruby's conservative nature of GC. Hm, not sure what exactly you mean. I was assuming, the line wr = WeakRef.new Object.new leads to exactly one ref (the weak ref to be precise) to the instance. Anyway, can I circumvent this by doing: def create; Object.new; end wk = WeakRef.new create ? Regards robert