开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜