Find number of bytes a particular Hash is using in Ruby
All I want to know is how many bytes Ruby is using for a particular Hash obj开发者_如何学运维ect. How do I do that?
In tenderlove's talk on Ruby 1.9 at GoGaRuCo 2010, I learned about some stuff added to ObjectSpace in 1.9 that would seem to do the trick.
require "objspace"
obj = {some:"STUFF"}
ObjectSpace.memsize_of(obj) # => you can imagine
Found some docs on objspace but a lot of it is Japanese. There's some English in there if you keep looking.
Still not sure how I can get the memory size of an object in 1.8.7 by using Ruby.
精彩评论