Hi,

In message "Re: [ ruby-Bugs-1988 ] objects never get garbage collected when requested via ObjectSpace._id2ref"
    on Fri, 3 Jun 2005 20:09:56 +0900, noreply / rubyforge.org writes:

|Submitted By: meinrad recheis  (henon)
|
|this is the expected behavior. the anonymous local object "s" gets garbage collected. however if i do a ObjectSpace._id2ref before garbage collection it somehow does not get recycled: 
|
|id="s".object_id
|p ObjectSpace._id2ref id
|GC.start
|p ObjectSpace._id2ref id
|
|results in -> "s"
|"s"
|
|seems that _id2ref does some caching. i think it is a bug, because it seems that the objects requested through _id2ref stay in memory forever.

_id2ref does no caching. There's no guarantee that any object to be
reclaimed when you don't see any reference to it for conservativeness
of Ruby's GC.  Conservative GC sometimes detect references from
machine stack and registers.  I recommend you to dispose explicitly if
you want to make it sure for certain point.

							matz.