Subject: | Memory Leak in module XBase takes place |
#Memory Leak in module XBase takes place.
#Object XBase::IndexCursor from package XBase::IndexCursor
#in file XBase.pm
#Example code
use strict;
use XBase;
my $fd='c:/foo.dbf';
my $fi='c:/foo.cdx';
my $table =XBase->new($fd) or die XBase->errstr;
my ($k,$cursor);
while($k<99999){
$cursor = $table->prepare_select_with_index([$fi, "KEY"]);
sleep 1;
print "$k\n";
$k++;
}
exit;
XBase version 1.02
ActivePerl
This is perl 5, version 14, subversion 1 (v5.14.1) built for MSWin32-
x86-multi-thread
Similar result for other versions ActivePerl - 5.8.9, 5.12.4
OS - WindowsXP SP3 Professional
Possibly problem that object XBase::IndexCursor contains references to
hashes.
I suggest to add a method close for class XBase::IndexCursor
sub close {
my $self = shift;
for (keys %{$self->[4]}){ delete $self->[4]->{"$_"}; }
}
#Example new code
use strict;
use XBase;
my $fd='c:/foo.dbf';
my $fi='c:/foo.cdx';
my $table =XBase->new($fd) or die XBase->errstr;
my ($k,$cursor);
while($k<99999){
$cursor = $table->prepare_select_with_index([$fi, "KEY"]);
$cursor->close;
sleep 1;
print "$k\n";
$k++;
}
exit;