Nobu:

The procObj does not refer to object 't'. procObj is attached as a
finalizer to object 't'. If the object reference to 't' is not stored
in the class variable, object 't' will be marked (or should I say
un-marked) for garbage collection.

Please correct me if I am wrong, or if I am missing the obvious (like
the reference to object 't' in procObj, which I cant see).

Thanks,
Madan.

On 5/19/06, nobu / ruby-lang.org <nobu / ruby-lang.org> wrote:
> Hi,
>
> At Fri, 19 May 2006 22:58:28 +0900,
> Madan Manoharan wrote in [ruby-talk:193553]:
> >   def getATest()
> >       procObj = Proc.new do |id|
> >         @store.delete(id)
> >       end
> >
> >       t = Test.new()
> >       @store.push(t.__id__)
> >
> >       ObjectSpace.define_finalizer(t, procObj)
> >       return t.__id__
> >   end
>
> Note that procObj also refers t, so this object will never get
> collected.
>
>       procObj = @store.method(:delete).to_proc
>
> is an alternative.
>
> --
> Nobu Nakada
>
>