Memory leak in connect and undef

Carlos Velasco <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
Hello,

Debugging a long term perl daemon for memory leaks I have found out that
just a DB connect and undef leaks.

This simple code leaks:
===
#!/usr/bin/perl

use DBI;

my $con;

$con = DBI->connect('DBI:mysql:database=test;host=127.0.0.1', 'root',
'pass', {PrintError => 0,PrintWarn=>0});
undef $con;
===

I used Devel::Leak and opened a bug in DBD::mysql
http://bugs.mysql.com/bug.php?id=66859

But the problem seems to be in DBI.

Using Devel::leak::Object reveals leaking in DBI::var.

This code:
===
#!/usr/bin/perl

# Track every object including where they're created
use Devel::Leak::Object qw{ GLOBAL_bless };
$Devel::Leak::Object::TRACKSOURCELINES = 1;

use DBI;

my $con;

for (1..1000) {
$con = DBI->connect('DBI:mysql:database=test;host=127.0.0.1', 'root',
'pass', {PrintError => 0,PrintWarn=>0});
$con->disconnect();
undef $con;
}
===

Outputs:
===
Tracked objects by class:
        Config                                   1
        DBI::var                                 5

Sources of leaks:
Config
     1 from /usr/lib64/perl5/5.16.1/x86_64-linux-thread-multi/Config.pm
line: 73
DBI::var
     5 from
/usr/lib64/perl5/site_perl/5.16.1/x86_64-linux-thread-multi/DBI.pm line: 306
===

I used DBI-1.622_901 (latest version I saw), and line 306 is:
sub DBI::var::TIESCALAR{ my $var = $_[1]; bless \$var, 'DBI::var'; }

Don't know how to debug this further.

Perl is 5.16.1
DBD::mysql is 4.022
mysql is mysql-5.5.27.tar.gz


Also, it seems these leaks have been there from long time ago:
https://bugs.launchpad.net/ubuntu/+source/libdbd-mysql-perl/+bug/51746

Regards,
Carlos Velasco
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.