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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Memory efficient way to deal with really large arrays?
by LanX (Saint) on Dec 13, 2020 at 13:01 UTC | |
by salva (Canon) on Dec 13, 2020 at 13:21 UTC |
In Section
Seekers of Perl Wisdom