http://qs1969.pair.com?node_id=11125100


in reply to Memory efficient way to deal with really large arrays?

Instead of using an array of arrays for storing the pairs, you can use two arrays, one for the first elements and another for the second ones. That is going to reduce your memory consumption by an order of magnitude:
my @d; my (@p1, @p2); for (my $i=0;$i<500000000;$i++) { my ($p1,$p2) = getPair(); $d[$p1]++; $d[$p2]++; push @p1, $p1; push @p2, $p2; }