On Thu, Aug 30, 2001 at 10:32:12AM +0200, Denis Pithon wrote:
> On 29 Aug 2001 22:43:29 +0200, Jan Matejka wrote:
> > I run both your tests on Windows 2000 with ActiveState
> > Perl 5.6.1 build 629, DBI 1.20 and DBD-Oracle 1.08.
> >
> > Test1 was eating memory slowly (104KB per 1000 iterations)
> > Test2 after 5000 iterations had NO memory leak at all !
I see similar results.
It doesn't leak unless execute() is called. It leaks faster if data is
fetched. But prepare/execute/fetch of more than one statement per
connection doesn't make it leak more. Odd.
I can't find the cause after a quick look. I've appended ths script
I've been using for leak testing so others can take a look. I'd also
be grateful if people could try this with other drivers incase the
leak (or leaks) are actually in the DBI somewhere.
> I retry it this morning...Test2 eats 4kb/s, it's not a dream :). There
> is no memory consumption with prepare/execute.
Here's the code that executes do():
sub do {
my($dbh, $statement, $attr, @params) = @_;
my $sth = $dbh->prepare($statement, $attr) or return undef;
$sth->execute(@params) or return undef;
my $rows = $sth->rows;
($rows == 0) ? "0E0" : $rows;
}
There's no reason for that to leak if prepare/execute doesn't leak.
Try also upgrading perl from your x.0 release to .1.
Tim.
#!/bin/env perl -w
use DBI;
$|=1;
print "DBI $DBI::VERSION\n";
my $exe = 1000;
for (1..100) {
print "\nConnection $_...\n";
my $dbh = DBI->connect("DBI:Oracle:", "scott/tiger", "") or die;
$dbh->trace(6) if $_ == 1;
#$dbh->{RowCacheSize} = 10000;
my $cnt = 0;
while (++$cnt <= $exe) {
my $sth = $dbh->prepare("select 1 from dual") or die;
#$sth->execute();
#$sth->fetchall_arrayref;
if ($cnt == 2) { # near first time of many
$dbh->trace(0);
ps();
}
print "." unless $cnt % 20;
}
print "after:\n" if $exe>1;
ps(); # last time
#system("kill -QUIT $$");
$dbh->disconnect;
undef $dbh;
}
sub ps { # show memory usage of this process
system("ps -l -p $$"); # XXX will need changing on some systems
}