Subject: | Big memory leak with XS part() |
Date: | Thu, 20 Nov 2008 06:28:41 -0800 |
To: | bug-List-MoreUtils [...] rt.cpan.org |
From: | "m c" <rossiya2 [...] gmail.com> |
Running sample program below causes a big memory leak, while toggling
to pure perl smart() does not.
Apparently this trouble is narrowed down to the XS version of part().
use List::MoreUtils qw(part);
sub smart(&@) {
my ($code, @list) = @_;
my @parts;
push @{ $parts[$code->($_)] }, $_ for @list;
return @parts;
}
while (1)
{ my $i = 0;
# my @part = smart { $i++ % 2 } 1 .. 8; # returns [1, 3, 5, 7], [2, 4, 6, 8]
my @part = part { $i++ % 2 } 1 .. 8; # returns [1, 3, 5, 7], [2, 4, 6, 8]
}
BOX SPECS:
$VERSION = '0.22';
$ uname -a
FreeBSD pocket.mydomain.net 7.0-RELEASE FreeBSD 7.0-RELEASE #1: Wed
Mar 5 22:46:53 PST 2008 kochevnik@:/usr/obj/usr/src/sys/CUSTOM2
i386
$ perl -v
This is perl, v5.8.8 built for i386-freebsd-thread-multi-64int
(with 1 registered patch, see perl -V for more detail)
MEMORY USAGE 5 MINUTES RUNNING smart()
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
45863 kochevnik 1 115 0 5416K 3408K RUN 0 3:13 92.58% perl
MEMORY USAGE 5 MINUTES RUNNING XS part()
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
49209 kochevnik 1 114 0 563M 561M RUN 0 2:34 86.67% perl