Posted on 2007-07-18 06:00:49-07 by sortiz
XBase.pm leaks memory
Using perl 5.8.4 some thing simple like
for(1..10000) { my $table = XBase->new('foo.dbf'); $table->close(); }

show that XBase leaks memory, thats because internally $table uses some closures that capture $self creating circular references that avoids proper destruction. The following patch cures that:
--- DBD-XBase-0.241/lib/XBase.pm.orig 2007-07-18 00:15:29.000000000 -0500 +++ DBD-XBase-0.241/lib/XBase.pm 2007-07-18 01:05:06.000000000 -0500 @@ -306,6 +306,7 @@ if (defined $self->{'memo'}) { $self->{'memo'}->close(); delete $self->{'memo'}; } + delete @{$self}{qw(field_wproc field_rproc)}; $self->SUPER::close(); }
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.