use Devel::Size qw( size total_size ); my $cache_array = []; $cache_array->[0x10fffd] = 2; say size( $cache_array ); # 8_912_944 say total_size( $cache_array ); # 8_912_968 my $cache_hash = {}; $cache_hash->{0x10fffd} = 2; say size( $cache_hash ); # 185 say total_size( $cache_hash ); # 209