in reply to Re^3: mem usage
in thread mem usage

You can trim your shuffle a little by omitting the line: next if $i==$j;

Good point!