From: Masaki Suketa Date: 2007-05-28T21:52:39+09:00 Subject: [ruby-list:43574] The behavior of GC 助田です。 [ruby-talk:253090]に関連したことなのですが、 次のスクリプトは (1) xlの指していたオブジェクトはGCされるので [] [#] [] となる。 (2) xlの指していたオブジェクトはGCされず [] [#] [#] となる。 (3) (1)、(2)のどちらとも言えない。時と場合による。 のどれが本来の動作なんでしょうか? --- ここから --- class Foo end def puts_objects res = [] ObjectSpace.each_object do |o| res << o if o.is_a? Foo end puts res.inspect end puts_objects # --> empty xl = Foo.new puts_objects # --> one object xl = nil GC.start puts_objects # --> the object is still or not? --- ここまで --- 助田 雅紀