use Devel::Size 'total_size'; $ARY[ $_ ] = ? for 1 .. 1_000_000; print total_size( \ @ARY ) . "\n"; # Do this as a comparison of a sparse array $ARY_B[ 1_000_000 ] = 1; print total_size( \ @ARY_B );