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.
In response to
pgsql-hackers by date
|Next:||From: Robert Haas||Date: 2009-08-23 13:37:02|
|Subject: Re: 8.5 release timetable, again|
|Previous:||From: Roger Leigh||Date: 2009-08-23 10:32:38|
|Subject: Re: Unicode UTF-8 table formatting for psql text output|
pgsql-bugs by date
|Next:||From: Dean Schulze||Date: 2009-08-23 22:59:49|
|Subject: BUG #5005: unique constraint considers nulls to be equal|
|Previous:||From: Hiroshi Inoue||Date: 2009-08-23 09:43:43|
|Subject: Re: BUG #4991: problem with ODBC driver 8.4|