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: | 4A9121D8.3060809@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-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:
http://www.cplusplus.com/reference/string/string/c_str/
So, no, there's no leak there.
--
Craig Ringer
From | Date | Subject | |
---|---|---|---|
Next Message | Dean Schulze | 2009-08-23 22:59:49 | BUG #5005: unique constraint considers nulls to be equal |
Previous Message | Hiroshi Inoue | 2009-08-23 09:43:43 | Re: BUG #4991: problem with ODBC driver 8.4 |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2009-08-23 13:37:02 | Re: 8.5 release timetable, again |
Previous Message | Roger Leigh | 2009-08-23 10:32:38 | Re: Unicode UTF-8 table formatting for psql text output |