From: nobu@... Date: 2006-07-07T00:10:11+09:00 Subject: Re: GC oddness Hi, At Thu, 6 Jul 2006 23:58:27 +0900, Alex Young wrote in [ruby-talk:200382]: > Can someone smarter tell me why this fails? I'm expecting the TestDir > to get GC'd when I call GC.start in the test, but something's obviously > keeping a reference lying around. I just can't see what it is... The finalizer proc refers testdir. > ---------------------- > require 'test/unit' > require 'fileutils' > > class TestDir > def TestDir.finalizer(dir) proc{|id| > FileUtils.rm_rf(dir) > } > end > def initialize(dir) > FileUtils.mkdir(dir) ObjectSpace.define_finalizer(self, TestDir.finalizer(dir)) > end > end -- Nobu Nakada