Ruby Enterprise のObjectSpace.statistics
Ruby EnteripriseにはObjectSpace.statisticsなるメソッドがあります。
> ruby -e 'GC.copy_on_write_friendly = true;GC.start;print ObjectSpace.statistics' Number of objects : 3476 (3110 AST nodes, 89.47%) Heap slot size : 20 GC cycles so far : 1 Number of heaps : 1 Total size of objects: 67.89 KB Total size of heaps : 195.33 KB (127.44 KB = 65.24% unused) Leading free slots : 6523 (127.40 KB = 65.22%) Trailing free slots : 0 (0.00 KB = 0.00%) Number of contiguous groups of 16 slots: 407 (65.11%) Number of terminal objects: 188 (1.88%)
CRubyにも欲しいなー。しかも、ストリングではなく、ハッシュテーブルで返ってくるとなおいいですね。