Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 16054
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: dmitry [...] karasik.eu.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.43
Fixed in: 1.44



Subject: Memory leak in DBD::Pg-1.43
The following code illustrates a memory leak that appears when a prepared statement is repeatedly executed with defined and undefined parameters. use strict; use DBI; my $dbh = DBI->connect("dbi:Pg:dbname=template1", (($^O =~ /linux/) ? "postgres" : "pgsql"), ''); die "DBI->connect: $DBI::errstr" unless $dbh; my $sth = $dbh-> prepare( "SELECT ?::text;"); while ( 1) { $sth-> execute( '1' x 100_000); $sth-> fetchrow_arrayref; $sth-> execute(undef); $sth-> fetchrow_arrayref; }
And this patch seems to fix it -- although I didn't scan for other places that may need a Safefree --- dbdimp.c.1 Wed Nov 23 22:20:09 2005 +++ dbdimp.c Wed Nov 23 22:20:05 2005 @@ -1508,6 +1508,7 @@ currph->value[currph->valuelen] = '\0'; } else { + Safefree(currph->value); currph->value = NULL; currph->valuelen = 0; }
I'm just curious, are RT bugs forwarded to the devlopers at all? I'm willing to resubmit the patch to the proper place, I just wish I knew where.
From: David Wheeler <dwheeler [...] cpan.org>
Subject: Re: [cpan #16054] Memory leak in DBD::Pg-1.43
Date: Wed, 23 Nov 2005 13:47:16 -0800
To: bug-DBD-Pg [...] rt.cpan.org
RT-Send-Cc:
On Nov 23, 2005, at 1:29 PM, via RT wrote: Show quoted text
> I'm just curious, are RT bugs forwarded to the devlopers at all? I'm > willing to resubmit the patch to the proper place, I just wish I > knew where.
Yes, they get sent to the DBD::Pg mail list. Or they should be sent there. Best, David
From: Tom Lane
Also see http://archives.postgresql.org/pgsql-general/2005-11/msg01352.php which reports a small client-side memory leak. I've been able to reproduce it using perl-DBD-Pg-1.41-2 on Fedora. May or may not be the identical issue --- that test case doesn't have any prepared statement. Note: you don't need to bother preloading the table as stated in the report. Just make the table and index, run the perl program, and watch the perl process memory size...
I'm afraid that is a completely different issue -- the original bug report relates to a memory leak in the client side, whereas http://archives.postgresql.org/pgsql-general/2005-11/msg01352.php is all about the memory that leaks in the server. JIC, I wasn't able to reproduce the server leak on postgres-8.2-devel.
Show quoted text
> JIC, I wasn't able to reproduce the server leak on postgres-8.2-devel.
forgot to add, there's also no client leak using DBD::Pg-1.43 with the above bug fixed.