From: khaines@... Date: 2007-01-12T23:13:50+09:00 Subject: Re: Garbage collection and Arrays On Fri, 12 Jan 2007, Aaron Patterson wrote: > Hi, I seem to be running in to some garbage collection weirdness. > Hopefully someone will have some insight for me.... My sample script > seems to leak Strings when I use shift on an Array, but not pop: > > array = [] > 10.times { array << "foo" } > 10.times { array.pop } # Change this to shift to see a leak > > o_count = Hash.new(0) > GC.start > ObjectSpace.each_object { |o| o_count[o.class] += 1 } > > o_count.sort_by { |k,v| -v}.each { |k,v| puts "#{k}: #{v}" } > > Is this a bug? Or is there something I'm missing? Thanks! Check the archives of the list for extensive discussion. The upshot is that it's a problem with this shift() method. Kirk Haines