Re: Memory leak in DBI ?

Tim Bunce <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
I trust the script is destroying the results and, where appropriate,
the $sth before calling Devel::Leak::CheckSV.

Could you post the script?

Tim.

On Thu, Apr 10, 2008 at 01:00:09PM +0200, Philippe Bruhat (BooK) wrote:
> Hi,
> 
> While looking for memory leaks in our code using Devel::Leak, we
> pinpointed one of them to a call to selectcol_arrayref().
> 
> The attached script tries several DBI commands on various DBD drivers
> (it's easy to add one, or to add code to be tested for leakage), and
> reports how much leakage Devel::Leak caught.
> 
> Just to be sure that we're not mistaking for a leak some Perl/DBI internal
> structures that are initialized the first time the code is called,
> we run every command twice, and only look for leakage the second time.
> 
> It is very possible that the test script takes something expected for
> a memory leak, but I've tried to make it only report valid leaks. (try
> removing the first eval $cmd from the test script to see the difference)
> 
> Devel::Leak is *very* verbose (even more with a Perl compiled for
> debugging), so if you're only interested in the results, run:
> 
>     perl dbi_leak.t 2>&1 | grep ok
> 
> Here, with Perl 5.8.8, DBI 1.602, DBD::CSV 0.22, DBD::SQLite 1.14,
> DBD::mysql 4.006, I get the following results:
> 
>     ok 1 - leak = 0 for csv     my $sanity = 1;
>     not ok 2 - leak = 9 for csv     my $s = $dbh->prepare( $sql ); $s->execute(); 1 while $s->fetchrow_arrayref(); $s->finish;
>     not ok 3 - leak = 1 for csv     my $s = $dbh->prepare_cached( $sql ); $s->execute(); 1 while $s->fetchrow_arrayref(); $s->finish;
>     not ok 4 - leak = 2 for csv     my $c = $dbh->selectcol_arrayref( $sql, { Column => [1] } )
>     not ok 5 - leak = 2 for csv     my @a = $dbh->selectrow_array( $sql )
>     not ok 6 - leak = 2 for csv     my $a = $dbh->selectrow_arrayref( $sql )
>     ok 7 - leak = 0 for mysql   my $sanity = 1;
>     not ok 8 - leak = 1 for mysql   my $s = $dbh->prepare( $sql ); $s->execute(); 1 while $s->fetchrow_arrayref(); $s->finish;
>     ok 9 - leak = 0 for mysql   my $s = $dbh->prepare_cached( $sql ); $s->execute(); 1 while $s->fetchrow_arrayref(); $s->finish;
>     not ok 10 - leak = 1 for mysql   my $c = $dbh->selectcol_arrayref( $sql, { Column => [1] } )
>     not ok 11 - leak = 1 for mysql   my @a = $dbh->selectrow_array( $sql )
>     not ok 12 - leak = 1 for mysql   my $a = $dbh->selectrow_arrayref( $sql )
>     ok 13 - leak = 0 for sqlite  my $sanity = 1;
>     not ok 14 - leak = 1 for sqlite  my $s = $dbh->prepare( $sql ); $s->execute(); 1 while $s->fetchrow_arrayref(); $s->finish;
>     ok 15 - leak = 0 for sqlite  my $s = $dbh->prepare_cached( $sql ); $s->execute(); 1 while $s->fetchrow_arrayref(); $s->finish;
>     not ok 16 - leak = 1 for sqlite  my $c = $dbh->selectcol_arrayref( $sql, { Column => [1] } )
>     not ok 17 - leak = 1 for sqlite  my @a = $dbh->selectrow_array( $sql )
>     not ok 18 - leak = 1 for sqlite  my $a = $dbh->selectrow_arrayref( $sql )
>     # Looks like you failed 13 tests of 18.
> 
> I've been told that it also leaks on 5.10.0.
> 
> 
> -- 
>  Philippe Bruhat (BooK)
> 
>  The truly stupid always find a way to create disaster.
>                                                 (Moral from Groo #10 (Image))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.