本日のはまりコード
以下のプログラムを動かすと激しくメモリリーク
use List::Util;
my @parent;
for ( 1..4 ) {
push @parent, {
key => "parent_" . $_,
value => $_
};
}
while (1) {
my $child = rand(4);
my $hit = List::Util::first { $_->{value} > $child } @parent;
$hit ||= $parent[0];
print "$hit->{key}\n";
}
List::Util::firstでのリファレンスが解放できないのかなぁ。。
仕方ないのでforeachで書き直した。
__追記
1.18では直っている模様
1.18 -- Fri Nov 25 09:30:29 CST 2005 Bug Fixes * Fix memory leak in first() and reduce()