Subject: | each_arrayref leaks |
List::MoreUtils each_arrayref leaks. I've tested this in both 0.22 and
0.25_02. Reproduction script attached.
Output for version 0.22 on 500 iterations:
--- 0---> process size: 5566464
--- 1---> process size: 5697536
--- 2---> process size: 5689344
--- 3---> process size: 5689344
--- 4---> process size: 5689344
--- 5---> process size: 5689344
--- 50---> process size: 5689344
--- 100---> process size: 5689344
--- 150---> process size: 5824512
--- 200---> process size: 5955584
--- 250---> process size: 5955584
--- 300---> process size: 6086656
--- 350---> process size: 6086656
--- 400---> process size: 6217728
--- 450---> process size: 6217728
--- 500---> process size: 6348800
Output for version 0.25_02 on 500 iterations:
--- 0---> process size: 5984256
--- 1---> process size: 6119424
--- 2---> process size: 6119424
--- 3---> process size: 6119424
--- 4---> process size: 6119424
--- 5---> process size: 6119424
--- 50---> process size: 6119424
--- 100---> process size: 6119424
--- 150---> process size: 6250496
--- 200---> process size: 6250496
--- 250---> process size: 6381568
--- 300---> process size: 6512640
--- 350---> process size: 6512640
--- 400---> process size: 6643712
--- 450---> process size: 6643712
--- 500---> process size: 6774784
(I ran these on a i386-linux-thread-multi system with perl 5.8.8.)
Subject: | each_arrayref.pl |
use strict;
use warnings;
#use local::lib '~/perl5';
use List::Util 'first';
use List::MoreUtils 'each_arrayref'; #, '0.25_02';
use Proc::ProcessTable;
use Data::Dumper;
sub iteration
{
my $list1 = [ 'a' .. 'z'];
my $list2 = [ 1 .. 26 ];
my $iter = each_arrayref($list1, $list2);
while (my ($letter, $index) = $iter->())
{
my $str = "$letter -> $index";
#print $str, "\n";
}
}
sub memsz
{
my $table = Proc::ProcessTable->new;
my $proc = first { $_->pid == $$ } @{$table->table};
return $proc->size;
}
# main loop
{
my $iters = $ARGV[0] || 500;
my $start_size = memsz;
print sprintf("---%4d--->", 0),
" process size: ", $start_size, "\n";
my $end_size;
foreach my $i (1..$iters)
{
iteration;
# every 20 iters, pause briefly and then get process size.
next if ($i > 5) and ($i % 50) and ($i != $iters);
sleep 1;
my $memsize = memsz;
$end_size = $memsize;
print sprintf("---%4d--->", $i),
" process size: ", $memsize, "\n";
}
print "\n",
sprintf("Start size: %10d, end size: %10d, delta: %10d",
$start_size,
$end_size,
($end_size - $start_size)),
sprintf(", leak per iteration: %.5f", (($end_size - $start_size) / $iters)),
"\n";
}