```{index} single: Devel::Size ``` # Devel::Size ```{pperl-module-badges} Devel::Size ``` `Devel::Size` - how much memory a Perl variable uses. ```perl use Devel::Size qw(size total_size); my $bytes = size("A string"); # the scalar itself my @list = (1 .. 1000); my $flat = size(\@list); # the array, not its elements my $deep = total_size(\@list); # the array and all it holds ``` `size` counts a variable and the memory it owns directly: a scalar's string buffer, an array's slot vector, a hash's buckets and keys. `total_size` also follows what an array or hash contains, and what references point to, counting each thing reachable once. Pass a reference to measure an array, a hash or a code reference. The numbers are the sizes of the interpreter's own structures, laid out as perl 5.44 lays them out, so they agree with perl 5.44 running the XS Devel::Size. `$Devel::Size::warn` (default 1) turns the module's warnings about sizes it cannot work out completely on or off; `$Devel::Size::dangle` (default 0) enables warnings about invalid pointers met on the way. This is a native implementation of the CPAN distribution Devel-Size 0.87; its `Devel/Size.pm` is used unchanged. ## Functions ### Other Functions #### `size` `size($thing)` (`ix` 0) / `total_size($thing)` (`ix` 2, its ALIAS): bytes used by `$thing`, or by what a reference points to. Also available as `Devel::Size::total_size`.