Skip site navigation (1) Skip section navigation (2)

Re: BUG #4996: postgres.exe memory consumption keeps going up

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4996: postgres.exe memory consumption keeps going up
Date: 2009-08-23 11:02:48
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugspgsql-hackers
On 23/08/2009 12:42 PM, Greg Stark wrote:
> On Sun, Aug 23, 2009 at 4:48 AM, Craig
> Ringer<craig(at)postnewspapers(dot)com(dot)au>  wrote:
>> Interestingly, though, the test program does appear to be leaking - at
>> least, the peak working set slowly climbs. It's all private working set. Not
>> sure why yet since the memory use looks like it _should_ be constant.
> How does the return value of str() get cleaned up here?
>                  PGresult* res=PQexec(conn,insert.str().c_str());

str() returns a std::string instance by value. It's not returning a 
pointer to a heap allocated object. The returned std::string is cleaned 
up when it leaves scope - in this case, at end-of-statement.

c_str() is called on the temporary std::string . This returns a const 
char * to a block of memory owned by the std::string . It must *NOT* be 
freed by the caller or modified by the caller. It's usually just the 
internal buffer maintained by the std::string. See:

So, no, there's no leak there.

Craig Ringer

In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2009-08-23 13:37:02
Subject: Re: 8.5 release timetable, again
Previous:From: Roger LeighDate: 2009-08-23 10:32:38
Subject: Re: Unicode UTF-8 table formatting for psql text output

pgsql-bugs by date

Next:From: Dean SchulzeDate: 2009-08-23 22:59:49
Subject: BUG #5005: unique constraint considers nulls to be equal
Previous:From: Hiroshi InoueDate: 2009-08-23 09:43:43
Subject: Re: BUG #4991: problem with ODBC driver 8.4

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group