Created
June 14, 2013 18:33
-
-
Save jzawodn/5784173 to your computer and use it in GitHub Desktop.
Demonstrate the leak in DBD::mysql that I noticed. If you fail to connect (down host), the program will leak memory. If you're connecting to a server that's up, there is no leak.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: $@"; | |
} | |
} | |
exit; | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment