On Thu, 10 Apr 2008 13:00:09 +0200, "Philippe Bruhat (BooK)"
<[EMAIL PROTECTED]> wrote:

> Hi,
> 
> While looking for memory leaks in our code using Devel::Leak, we
> pinpointed one of them to a call to selectcol_arrayref().

There was also a leak in Text::CSV_XS, which was fixed in version 0.37
I'm not sure - but I think so - if DBD::CSV uses Text::CSV_XS

> 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.

-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.10.x  on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin.       http://qa.perl.org
http://mirrors.develooper.com/hpux/            http://www.test-smoke.org
                        http://www.goldmark.org/jeff/stupid-disclaimers/

Reply via email to