memory leak in loop

M

Mike Solomon

Using the following code I get a memory leak

I am using ActiveState Perl 5.8.0 on Windows

I suspect it is caused by Xbase

Any ideas to fix it would be much appreciated

use strict;
use XBase;


for (0 .. 100000000) { Process($_); sleep 3;}

exit;

sub Process {
my ($counter) = @_;

my $error;
my $dbf;
unless ($dbf = new XBase "survey.dbf") {
$error = XBase->errstr;
print $error;
}

#get last record from audit
my $last = $dbf->last_record;
$dbf->close;
print "LAST RECORD FROM dbf $last $counter\n";
return;
}
__END__
 
S

Sisyphus

Mike Solomon said:
Using the following code I get a memory leak

I am using ActiveState Perl 5.8.0 on Windows

I suspect it is caused by Xbase

Any ideas to fix it would be much appreciated

use strict;
use XBase;

That module has not been updated on cpan in over 9 years. Maybe try using
DBD::Xbase instead. (It's available as a ppm from ActiveState.)

Cheers,
Rob
 
M

Mike Solomon

Sisyphus said:
That module has not been updated on cpan in over 9 years. Maybe try using
DBD::Xbase instead. (It's available as a ppm from ActiveState.)

Cheers,
Rob


Same problem with DBD:Xbase I'm afraid
 
S

Sisyphus

Mike Solomon said:
"Sisyphus" <[email protected]> wrote in message


Same problem with DBD:Xbase I'm afraid

Bummer ..... I guess the problem arises because you call new() at each
iteration. Do you need to do that ? Does it make any difference if you
'undef($dbh);' at the end of the loop (just after '$dbh->close;') ? Other
than that, if there's no help forthcoming, I would try contacting the
author - in fact it would be a good idea to let him know of the problem,
anyway.

Cheers,
Rob
 
M

Mike Solomon

Sisyphus said:
Bummer ..... I guess the problem arises because you call new() at each
iteration. Do you need to do that ? Does it make any difference if you
'undef($dbh);' at the end of the loop (just after '$dbh->close;') ? Other
than that, if there's no help forthcoming, I would try contacting the
author - in fact it would be a good idea to let him know of the problem,
anyway.

Cheers,
Rob

If I don't call new it doesnt reread the file

undef makes no difference I'm afraid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Memory leak with threads 16
cannot solve a memory leak 3
Support for dbmopen/dbmclose? 2
runaway memory leak with LWP and Fork()ing on Windows 4
memory leak? 0
Memory leak 8
Possible memory leak? 11
Memory leak 8

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top