How big?

acme on 2007-01-31T14:42:39

Memory is cheap and a common Perl trick is to trade memory for performance - but how do you know how much memory a data structure is using? With Devel::Size and Number::Bytes::Human:

warn '$photos takes up ' . format_bytes( total_size($photos) ) if $DEBUG;

This outputs something like:

$photos takes up 2.3M

2.3M! That's so small, I can easily stick a hundred times more photos in there before worrying about memory usage. I'll go add some more functionality instead of prematurely optimising...


Calculating memory usage

scot on 2007-01-31T20:58:45

Thanks for the tip++! I've been wondering how to do that.