Memory leak problem

From: "Tim Barnard" <tbarnard(at)povn(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Memory leak problem
Date: 2002-04-04 23:58:03
Message-ID: 018901c1dc34$8f4294c0$a519af3f@hartcomm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In the process of tracking down a bug in my application I came across a
possible memory leak problem in 7.2.1. In my code I had a situation where
"begin" was followed by a "close cursor1" followed by a "commit". Obviously
a coding error on my part but the question is should this sequence of steps
have caused a memory leak?

Here's a trivial example that'll demonstrate what I'm talking about:
(While monitoring with "top -d 1" it takes about 15 seconds or so before
memory used starts dramatically increasing)

NOTE: Omitting "close cursor1" and its subsequent PQclear causes the
apparent leak to not occur.
Also, the usual error trapping has been omitted from the code below.

#include "libpq-fe.h"

int main( int argc, char ** argv )
{
PGconn * con_p;
PGresult * rslt_p;
con_p = PQconnectdb( "dbname=cvm" );
if( con_p == NULL || PQstatus( con_p ) == COMMAND_BAD )
{
... error logging, blah, blah...
}
while( true )
{
rslt_p = PQexec( "begin" );
PQclear( rslt_p );
rslt_p = PQexec( "close cursor1" );
PQclear( rslt_p );
rslt_p = PQexec( "commit" );
PQclear( rslt_p );
}
return( 0 );
}

Tim

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Michel POURE 2002-04-05 02:57:12 Re: no "ON INSERT ignore" in postgre?
Previous Message Command Prompt, Inc. 2002-04-04 21:05:32 Re: PostgreSQL on Windows or MS-SQLServer???