On Jan 9, 2008, at 9:39 AM, dan yoder wrote:

> I realize the scope of the lambda invocation is different in this
> example, but since the behavior is so similar, I thought it likely
> pointed to the same underlying issue.

i think it's actually some strange interaction with yaml.  check this  
out:

cfp2:~ > cat a.rb
class Class
   def finalizer
     lambda{}
   end

   def new *a, &b
     object = allocate
     object.send :initialize, *a, &b
     object
   ensure
     ObjectSpace.define_finalizer object, finalizer
   end
end

class Foo; end
class Bar < Foo; end


c = Array

if ARGV.detect{|arg| arg["leak"]}
  require "yaml"
  7.times {
    GC.start
    y c.name => ObjectSpace.each_object(c){}
    c.new
  }
else
  7.times {
    GC.start
    puts "---"
    puts "#{ c.name }: #{ ObjectSpace.each_object(c){} }"
    c.new
  }
end

cfp2:~ > ruby a.rb
---
Array: 6
---
Array: 11
---
Array: 14
---
Array: 18
---
Array: 20
---
Array: 20
---
Array: 20


cfp2:~ > ruby a.rb leak
---
Array: 21
---
Array: 38
---
Array: 54
---
Array: 67
---
Array: 79
---
Array: 91
---
Array: 103

a @ http://codeforpeople.com/
--
share your knowledge.  it's a way to achieve immortality.
h.h. the 14th dalai lama