I hope Tim will chime in and correct me, but since I was the last reporter of 
leaks in the DBI, let me try my best:

I tried to reproduce your leak without success.  Perhaps you are not letting 
your test run for enough iterations.  DBI does cache some handles that it only 
releases every 120 calls.  So you could see what looks like a 1 SV leak, but 
you'll see that after 120 iterations they are all freed.

Try running 1000 iterations and see if you still experience a leak.

I recommend using DBD::Sponge (which comes with DBI) so that you are sure 
you're not seeing a leak in your driver.  Example code follows.  Please let us 
know what you find.

my $dbh = DBI->connect("dbi:Sponge:","","",{ RaiseError => 1 });
my $sth = $dbh->prepare(
   "SELECT * FROM FOO",
   { rows => [[qw/1 2/],[qw/3 4/]], NAME => [qw/a b/]}
);
$sth->execute();
while ( my ($a,$b) = $sth->fetchrow_array() ) {
   print "a:$a,b:$b\n";
}
$sth->finish;
$dbh->disconnect;

> -----Original Message-----
> From: Jonathan [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 23, 2006 04:52
> To: dbi-users@perl.org
> Subject: Re: possible leak in 1.52
> 
> 
> it definitely seems to be a leak, and i've been able to reproduce it
> outside of mod_perl
> 
> it seems that there are a few potential sources / behaviors
> 
>       a_      the statement handle created by a prepare never seems to
> expire
> in the lifetime of a db connection
>               i could trace this as far back as
>                       DBI::_new_handle
> 
>       b_ if i connect, run 100 'update x where y=z' , then disconnect, no
> SV are released
> 
>       c_ if i then undef my db handle, a lot of SV are freed - but i seem
> to have a 138 SV which are not released
> 
>       d_ if i reconnect , i seem to use only 15 more SV than the original
> connect- whereas the original connect used 231 SV over my test
> platforms 'weight'
> 
>       e_ if i undef the reconnect, I seem to have leaked 1 SV since the
> first disconnect
> 
> unfortunately, thats as far as my DBI knowledge can take me
> 

Reply via email to