Package: libdbd-pg-perl
Version: 1.41-1
Severity: important
libdbd-pg-perl leaks memory when using the execute() statement handle
method. Attached is a program that clearly illustrates the problem.
Simply run it (subsitute whatever you need in the connect string) and,
using 'top', watch as it eats more and more memory over time.
I discovered this because I run a nighly job which does a stat() on
all the files in my filesystem and sticks the results into a table.
Normally the process takes perhaps a couple of hours, but today it
took about 6, and the system was paging much more than usual. Top
showed the process eating a gigabyte of memory when all was said and
done (it had inserted, via the execute(), some 2.5 million rows by
then).
The amount of memory leaked per execute() action appears to be related
to the size of the prepared statement, or perhaps to the number of
arguments needed. I haven't bothered to empirically determine which
is the case here, but it's why the prepared statement in the sample
code is as "large" as it is (given what it's doing) -- it makes the
memory leak a bit more obvious.
I haven't tested whether or not the memory gets freed when the
statement handle is closed. I figured it would probably be sufficient
to submit the bug with a program that shows it in action.
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.10-1-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages libdbd-pg-perl depends on:
ii libc6 2.3.2.ds1-21 GNU C Library: Shared libraries an
ii libdbi-perl 1.46-6 Perl5 database interface by Tim Bu
ii libpq3 7.4.7-5 PostgreSQL C client library
ii perl 5.8.4-8 Larry Wall's Practical Extraction
ii perl-base [perlapi-5.8.4] 5.8.4-8 The Pathologically Eclectic Rubbis
-- no debconf information
--
Kevin Brown [EMAIL PROTECTED]
#!/usr/bin/perl
use strict;
use DBI;
my $dbh;
my $sth;
my $n = 0;
select(STDOUT);
$| = 1;
$dbh = DBI->connect("DBI:Pg:dbname=kevin", undef, undef, {AutoCommit => 0}) || die "blah!";
$dbh->do("CREATE TABLE footemp (x integer, y integer)");
$sth = $dbh->prepare("UPDATE footemp SET x = 1 WHERE y = ? AND x = ? AND y = ? AND x = ? AND y = ? AND x = ? AND y = ? AND x = ? AND y = ? AND x = ? AND y = ? AND x = ?");
while (1) {
$sth->execute(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
$n++;
print "." if ($n % 1000 == 0);
print "\n" if ($n % 75000 == 0);
}