Opened 4 years ago

Last modified 3 years ago

#285 new defect

Memory Leak

Reported by: Asela Fernando Owned by: jtv
Priority: high Component: connections
Severity: Other Keywords: memory, leak, connection
Cc:

Description

Postgres Version "PostgreSQL 9.1.9"
Libpqxx Version 4.0.1
Libpq Version 5

Having a simple program such as

int main() {
 pqxx::connection conn("host=localhost dbname=test user=test password=test");
 return 0;
}

is enough for valgrind to pickup on a memory leak:

==16103== HEAP SUMMARY:
==16103==     in use at exit: 126,488 bytes in 2,788 blocks
==16103==   total heap usage: 4,478 allocs, 1,690 frees, 981,129 bytes allocated
==16103== 
==16103== 300 (60 direct, 240 indirect) bytes in 1 blocks are definitely lost in loss record 248 of 298
==16103==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==16103==    by 0x709FCD4: nss_parse_service_list (nsswitch.c:678)
==16103==    by 0x70A0795: __nss_database_lookup (nsswitch.c:175)
==16103==    by 0xE5EC623: ???
==16103==    by 0x705944C: getpwuid_r@@GLIBC_2.2.5 (getXXbyYY_r.c:256)
==16103==    by 0x7377558: ??? (in /usr/lib/libpq.so.5.4)
==16103==    by 0x7365E17: ??? (in /usr/lib/libpq.so.5.4)
==16103==    by 0x7374ADB: ??? (in /usr/lib/libpq.so.5.4)
==16103==    by 0x73764DD: ??? (in /usr/lib/libpq.so.5.4)
==16103==    by 0x7366CCD: PQconnectPoll (in /usr/lib/libpq.so.5.4)
==16103==    by 0x7367E9D: ??? (in /usr/lib/libpq.so.5.4)
==16103==    by 0x736887E: PQconnectdb (in /usr/lib/libpq.so.5.4)
==16103== 
==16103== LEAK SUMMARY:
==16103==    definitely lost: 60 bytes in 1 blocks
==16103==    indirectly lost: 240 bytes in 10 blocks
==16103==      possibly lost: 0 bytes in 0 blocks
==16103==    still reachable: 126,188 bytes in 2,777 blocks
==16103==         suppressed: 0 bytes in 0 blocks
==16103== Reachable blocks (those to which a pointer was found) are not shown.

Change History (3)

comment:1 Changed 4 years ago by RichardWef

  • version changed from 4.0 to 2.5
Last edited 3 years ago by jtv (previous) (diff)

comment:2 Changed 3 years ago by jtv

I'm not getting this, when using hostname=/run/postgresql/. Are you sure this isn't just a normal memory allocation during DNS resolution?

comment:3 Changed 3 years ago by jtv

  • milestone 3.1 deleted

Milestone 3.1 deleted

Note: See TracTickets for help on using tickets.