tags:

views:

37

answers:

1

Hi,

I'm having Memcache problems and I was wondering what is the best way to know how big the objects I create are.

The only solution I have is to put them into Memcache which display their size in bytes (by the way, can I customize Memcache's output? I want readable kilobytes…).

Thank you,

Kevin

+1  A: 

The excellent Eigenclass blog had an interesting article on that once:

http://eigenclass.org/R2/writings/object-size-ruby-ocaml

There also was a good discussion on ruby-talk, which led to some code by Robert Klemme (Ruby Best Practices):

http://www.ruby-forum.com/topic/156648

http://www.pastie.org/217131

Plugging the values from the first article into the script might get you started and is probably quite educational.

You could also check out memprof, though it's more about object references and finding memory leaks than actual sizes:

http://github.com/ice799/memprof

Michael Kohl
Okay, I just realized that, because memory allocation is different for every implementation, my problem is way more complicated than I thought :-)
Kevin