From: nobu.nokada@... Date: 2005-06-19T13:10:13+09:00 Subject: Re: GC.disable not working? Hi, At Sun, 19 Jun 2005 06:32:44 +0900, Eric Mahurin wrote in [ruby-talk:145790]: > $stdout.sync=true > @ids = {} > 1000.times { |i| > print("[") > obj = "X"*i > id = obj.object_id > @ids[id] = true > ObjectSpace.define_finalizer(obj,method(:finalizer)) > GC.disable > print("{") > @ids.each_key { |id| > # go make sure all objects seem valid (test size) > ObjectSpace._id2ref(id).size > } > print("}") > GC.enable You enable GC here, so it can run by next GC.disable. Then an exception occurs after GC is disabled, therefore GC will be no longer enabled. > print("]") > } > > > I tried this on 1.8.2 and a 1.9 CVS version. In both it calls > the finalizer when GC is disabled (GC.enable==true). I thought > this would be impossible. I also get a recycled object error. Finailizers don't run immediately after the corresponding objects get collected. The `finalizer' runs at the process termination. > In the 1.9 version I'm using, it hangs while trying to finalize > one of the objects (@ids.delete(id) is where it hangs). It's a bug, I'll investigate it. -- Nobu Nakada