Re: BUG #4996: postgres.exe memory consumption keeps going up
От | Craig Ringer |
---|---|
Тема | Re: BUG #4996: postgres.exe memory consumption keeps going up |
Дата | |
Msg-id | 4A9121D8.3060809@postnewspapers.com.au обсуждение исходный текст |
Ответ на | Re: BUG #4996: postgres.exe memory consumption keeps going up (Greg Stark <gsstark@mit.edu>) |
Список | pgsql-bugs |
On 23/08/2009 12:42 PM, Greg Stark wrote: > On Sun, Aug 23, 2009 at 4:48 AM, Craig > Ringer<craig@postnewspapers.com.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
В списке pgsql-bugs по дате отправления: