counts = Hash.new{ 0 }
ObjectSpace.each_object do |o|
counts[o.class] += 1
end
# or
ObjectSpace.count_objects
# symbol will not be garbage collected
Symbol.all_symbols.count
# gem i heap_dump
require 'heap_dump'
# will automatically run GC.start
HeapDump.dump
# check if its just not be garbage collected
GC.start
# hook on native events
TracePoint.new { |tp|
p [tp.lineno, tp.event, tp]
}.enable
def hello_world
puts "hello"
end
hello_world
# I'm not a c guy. so...
以上是我的一些笔记,结果我用了上面所有的方法,最终发现问题不是 memory leak..
orz.