memory leak in script that uses 32-bit DBD::mysql driver on a 64-bit Linux host (openSUSE)

memory leak in script that uses 32-bit DBD::mysql driver on a 64-bit Linux host (openSUSE)

am 15.01.2008 09:27:51 von Igor Marnat

Hi All!

I have binary proprietary 32-bit Perl module that I forced to use,
therefore I use 32-bit Perl interpreter (ActivePerl 5.8.8).
I also have server with 32 Gigabyte of RAM, so I use 64-bit Linux
(openSUSE 10.3) (platform x86_64) in order to give much RAM to MySQL
server.

In order to connect to MySQL server, I need DBD::mysql driver.
It isn't included in perl-32bit*, so I built it manually from
DBD-mysql-4.006.tar.gz archive.

It seems to work but after a few days of usage we found that there are
memory leaks, program size constantly grows and finally it gets killed
by OS.

We generated test script (attached) and I can see using top that its size in memory grows constantly.
I tried to run it under valgrind and it shows also memory leaks.

By the way, I tried to build and install DBD::mysql from sources using CPAN, but this attempt failed.
CPAN loaded the sources, saw that current perl interpreter is 32-bit one and tried to run Makefile.PL
with parameter "C_FLAGS=-m32". Makemaker doesn't want to run with it and complains
"'C_FLAGS' is not a known MakeMaker parameter name".

Therefore I downloaded DBD::mysql sources and built it manyally.
Configuration :
"perl Makefile.PL --cflags="-I/usr/include/mysql -fmessage-length=0
-D_FORTIFY_SOURCE=2 -fstack-protector -g -DPIC -fPIC -DUNDEF_HAVE_INITGROUPS -fno-strict-aliasing -m32" --libs="-m32 -L/usr/lib/mysql -lmysqlclient -L/lib -lz -lcrypt -lnsl -lm -L/usr/lib -lssl -lcrypto" --ps-protocol".
It complained that LIBS parameter -m32 is unknown, and on a linking
stage 64-bit linker was called. Therefore I changed Makefile generated
by this "perl Makefile.PL ..." call and change "LD = gcc" string to
"LD = gcc -m32". Otherwise it tried to link 32-bit object files using
64-bit linker.


MySQL server is of 5.0.45 version, DBD::mysql is of 4.006 version.

Please help, what can we do in order to avoid memory leaks? Any help or idea, please.

If I run this script using 64-bit perl interpreter (/usr/bin/perl), it works ok and its size remain the same all the time.
If I remove DBD::mysql usage from the script, it works ok as well. Therefore I suppose that the problem is somewhere in DBD::mysql driver.

Test script:
============================================================ ======
#!/opt/ActivePerl-5.8/bin/perl -w

use strict;
use DBI;

my %CONNECTION_ATR = ();
$CONNECTION_ATR{PrintError}=0;
$CONNECTION_ATR{RaiseError}=1;

my $CONSTR = "dbi:mysql:billing:10.0.0.178:3306:cp1251";
my $LOGIN = "log";
my $PASSWORD ="pas";

my $DBH_MAIN;

$DBH_MAIN = DBI->connect("$CONSTR","$LOGIN","$PASSWORD", \%CONNECTION_ATR); #BD
$DBH_MAIN->do('SET CHARACTER SET koi8r');


my $date_agr = "2007-11-11";
my $ip_int = 1234567;
my $sql_str = "SELECT CLIENT_ID, XLS_NAME FROM clients WHERE IP_INT = $ip_int AND FROM_DATE<='".$date_agr."' AND TO_DATE>'".$date_agr."'";

for (my $j=1; $j<99999999; $j++)
{
my $sth = $DBH_MAIN->prepare($sql_str);
$sth->execute();
$sth->finish();
#print $j;

}
$DBH_MAIN->disconnect;
============================================================ ======


Best regards,
Igor Marnat
mailto:marny@rambler.ru


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org