#! perl -slw use strict; our $SIZE ||= 1_000_000; # Don't build the test array by assigning a list # cos that doubles the memory consumption which # then serves to conseal the extra consumed by the grep my @array; push @array, $_ for 1 .. $SIZE; printf 'Check ram before ripple'; ; #@array = grep not ($_ % 2), @array; my( $s, $d ); for( $s = $d = 0; $s < @array; $d++, $s++ ) { $array[ $s ] %2 and $s++, $array[ $d ] = $array[ $s ]; }; $#array = --$d; printf 'Check ram after ripple'; ; die 'M_S: Mismatch:', scalar @array, " @array[ 0, -1 ]" unless @array == $SIZE / 2 and "@array[ 0, -1 ]" eq "2 $SIZE"; __END__ P:\test>371457-mem Check ram before grep 21844 kb Check ram after grep 35856 kb P:\test>371457-mem Check ram before ripple 21,844 kb Check ram after ripple 21,860 kb