# too bad this didnt make it into 1.9 (Object#tap did) class Object def returning(&block) return yield(self) end end count = ObjectSpace.count_objects.returning { |h| h[:TOTAL] - h[:FREE] } 100_000.times do |i| String.new c = ObjectSpace.count_objects.returning { |h| h[:TOTAL] - h[:FREE] } if c < count puts "GC - Iteration #{i} - Was #{count} now #{c}" end count = c end