From: Alex Young Date: 2006-07-06T23:58:27+09:00 Subject: GC oddness Hi all, 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... ---------------------- require 'test/unit' require 'fileutils' class TestDir def TestDir.set_finalizer(testdir, dir) ObjectSpace.define_finalizer(testdir, proc{|id| FileUtils.rm_rf(dir) } end def initialize(dir) FileUtils.mkdir(dir) TestDir.set_finalizer(self, dir) end end class DestroyTest < Test::Unit::TestCase def test_destroy a = TestDir.new('test_dir') a = nil GC.start assert !File.directory?('test_dir') end end ---------------------------- It's got me a bit stumped. Thanks, -- Alex