Subject: | Memory Leak when connecting to a down server... |
Date: | Fri, 14 Jun 2013 11:54:14 -0700 |
To: | bug-DBD-mysql [...] rt.cpan.org |
From: | Jeremy Zawodny <Jeremy [...] Zawodny.com> |
(This was also filed on github but I'm not clear where the correct
place to report it really is.)
https://github.com/CaptTofu/DBD-mysql/issues/45
I was making use of the new async features in developing a new module
and came across a memory leak during testing. I was able to whittle
the test case down to something quite small.
The code is here: https://gist.github.com/jzawodn/5784173 and I'll
paste it in this bug report too.
If you put a valid user/password and host/port combo in the script, it
will stay at a fixed memory size. However, if the connection fails for
any reason (down host, bad username) the script will grow in memory
usage until terminated.
#!/usr/bin/perl -w
use strict;
use warnings;
use feature qw(say);
use DBD::mysql;
my $host = 'dev4h';
my $port = 9307;
my $dsn = "DBI:mysql:host=$host;port=$port";
my $user = 'foo';
my $pass = 'bar';
while (1) {
my $dbh = DBI->connect($dsn, $user, $pass);
if ($dbh) {
say "connected to $host:$port";
} else {
say "connect fail to $host:$port: $@";
}
undef $dbh;
}
exit;
__END__