NAME

Devel::Size - Perl extension for finding the memory usage of perl variables

SYNOPSIS

  use Devel::Size qw(size);
  $size = size("abcde");
  $other_size = size(\@foo);

  $foo = {a => [1, 2, 3],
	  b => {a => [1, 3, 4]}
         };
  $total_size = total_size($foo);

DESCRIPTION

This module figures out the real sizes of perl variables. Call it with a reference to the variable you want the size of. If you pass in a plain scalar it returns the size of that scalar. (Just be careful if you're asking for the size of a reference, as it'll follow the reference if you don't reference it first)

The size function returns the amount of memory the variable uses. If the variable is a hash or array, it only reports the amount used by the variable structure, not the contents.

The total_size function will walk the variable and look at the sizes of the contents. If the variable contains references those references will be walked, so if you have a multidimensional data structure you'll get the total structure size. (There isn't, at the moment, a way to get the size of an array or hash and its elements without a full walk)

EXPORT

None by default.

BUGS

Doesn't currently walk all the bits for code refs, globs, formats, and IO. Those throw a warning, but a minimum size for them is returned.

AUTHOR

Dan Sugalski dan@sidhe.org

SEE ALSO

perl(1).