Обсуждение: BUG #6234: Memory leak from PQexec
The following bug has been logged online: Bug reference: 6234 Logged by: Vikas Mehta Email address: mehta@roguewave.com PostgreSQL version: 8.4.8 Operating system: Windows Description: Memory leak from PQexec Details: Purify shows 448 bytes of memory leaks with PQexec: [W] Summary of all memory leaks... {448 bytes, 11 blocks} [W] MLK: Memory leak of 128 bytes from 1 block allocated in ERR_load_SSL_strings [SSLEAY32.DLL] [W] MLK: Memory leak of 128 bytes from 1 block allocated in PQrequestCancel [LIBPQ.DLL] [W] MLK: Memory leak of 128 bytes from 1 block allocated in ENGINE_load_ubsec [LIBEAY32.DLL] [W] MLK: Memory leak of 64 bytes from 8 blocks allocated in add_error_table [COMERR32.DLL] Test case: ========== #include <stdio.h> #include <stdlib.h> #include <string.h> #include <libpq-fe.h> void createTestTable(PGconn* dbc) { PGresult *res; printf("\n\nCreating Test Table.....\n"); res = PQexec(dbc, "create table mytable (col1 int)"); if (PQresultStatus(res) == PGRES_NONFATAL_ERROR || PQresultStatus(res) == PGRES_FATAL_ERROR) { printf("!!!!! Failed to create test table.\n"); } PQclear(res); } void dropTestTable(PGconn* dbc) { PGresult *res; printf("\n\nDropping Test Table.....\n"); res = PQexec(dbc, "drop table mytable"); if (PQresultStatus(res) == PGRES_NONFATAL_ERROR || PQresultStatus(res) == PGRES_FATAL_ERROR) { printf("!!!!! Failed to drop test table.\n"); } PQclear(res); } int main() { PGconn *dbc; dbc = PQconnectdb("host = magma.cvo.roguewave.com user = username password = pwd dbname = db"); if(dbc == 0 || PQstatus(dbc) == CONNECTION_BAD) { printf("!!!!! Failed to establish connection.\n"); } createTestTable(dbc); dropTestTable(dbc); PQfinish(dbc); return 0; }
On 29/09/2011 6:22 AM, Vikas Mehta wrote: > The following bug has been logged online: > > Bug reference: 6234 > Logged by: Vikas Mehta > Email address: mehta@roguewave.com > PostgreSQL version: 8.4.8 > Operating system: Windows > Description: Memory leak from PQexec > Details: > > Purify shows 448 bytes of memory leaks with PQexec: > > [W] Summary of all memory leaks... {448 bytes, 11 blocks} > [W] MLK: Memory leak of 128 bytes from 1 block allocated in > ERR_load_SSL_strings [SSLEAY32.DLL] > It's not a leak, and it's not a bug. Please search the pgsql-general archives for "valgrind" or "SSL_config". -- Craig Ringer
On Oct 4, 2011 2:14 AM, "Vikas Mehta" <Vikas.Mehta@roguewave.com> wrote: > > Thanks. I found posts on SSL leak reported by purify. However, I couldn't find any information on the memory leak from PQrequestCancel. Is it a known issue? It's essentially the same issue. OpenSSL loads some strings, config variables etc on demand/first use and doesn't bother to free them. This is fine because they are only ever loaded once, so there is no continuous growth with repeated invocations and no leak. Freeing them before program exit is hard because of ordering issues, so they just let the OS clean it up with the rest of the process's memory. That's perfectly correct. If repeat invocations of your problem code within one program session cause the heap to grow and the reported leak to get bigger / appear more times, THEN it is a real leak and a real bug. > > -----Original Message----- > From: Craig Ringer [mailto:ringerc@ringerc.id.au] > Sent: Friday, September 30, 2011 12:02 AM > To: Vikas Mehta > Cc: pgsql-bugs@postgresql.org > Subject: Re: [BUGS] BUG #6234: Memory leak from PQexec > > On 29/09/2011 6:22 AM, Vikas Mehta wrote: > > The following bug has been logged online: > > > > Bug reference: 6234 > > Logged by: Vikas Mehta > > Email address: mehta@roguewave.com > > PostgreSQL version: 8.4.8 > > Operating system: Windows > > Description: Memory leak from PQexec > > Details: > > > > Purify shows 448 bytes of memory leaks with PQexec: > > > > [W] Summary of all memory leaks... {448 bytes, 11 blocks} > > [W] MLK: Memory leak of 128 bytes from 1 block allocated in > > ERR_load_SSL_strings [SSLEAY32.DLL] > > > It's not a leak, and it's not a bug. Please search the pgsql-general archives for "valgrind" or "SSL_config". > > -- > Craig Ringer
VGhhbmtzLiBJIGZvdW5kIHBvc3RzIG9uIFNTTCBsZWFrIHJlcG9ydGVkIGJ5 IHB1cmlmeS4gSG93ZXZlciwgSSBjb3VsZG4ndCBmaW5kIGFueSBpbmZvcm1h dGlvbiBvbiB0aGUgbWVtb3J5IGxlYWsgZnJvbSBQUXJlcXVlc3RD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