Subject: | $op->sv memory leak introduced by B::Generate |
[I apologize if I report it twice, it does not look like the E-mail
report went anywhere]
Consider the following little test case:
----------8<-----------8<-----------8<-----------8<-----------8<------
#! /usr/bin/perl
use warnings;
use strict;
use Devel::Leak;
use B;
use B::Generate;
my $h;
print "0: ", Devel::Leak::NoteSV($h), "\n";
cc();
print "1: ", Devel::Leak::NoteSV($h), "\n";
cc();
print "2: ", Devel::Leak::NoteSV($h), "\n";
cc();
print "3: ", Devel::Leak::NoteSV($h), "\n";
sub cc {
check(sub { return "heps" . $_[0] . "be" . $_[1] . "4" });
}
sub check
{
my ($sub) = @_;
my $root = B::svref_2object($sub);
$root = $root->ROOT;
my @op = get_all_children($root);
for my $op (@op) {
if ($op->can("sv")) {
my $sv = $op->sv;
}
}
}
sub get_all_children
{
my ($op) = @_;
my @op;
if ($op->can("first")) {
push @op, $op->first, get_all_children($op->first);
}
if ($op->can("sibling")) {
push @op, $op->sibling, get_all_children($op->sibling);
}
@op;
}
----------8<-----------8<-----------8<-----------8<-----------8<------
On my machine, running this produces
0: 6517
1: 6874
2: 6879
3: 6884
If I comment out the "use B::Generate" statement above, the same code
produces
0: 5976
1: 6328
2: 6328
3: 6328
So there is a leak somewhere in the B::Generate's version of $op->sv.
Unfortunately, I lack the knowledge of perl guts to come up with a
patch,
but I do hope it is addressed.
The leak present at least in 1.11 and 1.12_06 tested on perl 5.8.8 on
several FreeBSD and Linux boxes.
Thanks for the module,
Cheers,
\Anton.