This is a stretch, but if your goal is to look for a memory leak, and not see the size of individual objects, you can look at object_count(cls) , as in:
>> ObjectSpace.each_object(Object).count => 114629 >> ObjectSpace.each_object(Array).count => 10209
etc .. FWIW, the characters are a little different: you can get the number of characters through:
>> Symbol.all_symbols.count => 17878
To find out if you have a leak, you can manually call GC, count your objects, run the code for a while, call GC again, and then see if the number of objects has increased.
Of course, this does not tell you about the size of each object, how much stands out from each class.
There is also memprof , but I admit that I have not used it yet.
fearless_fool
source share