[Libpqxx-general] Libpqxx-3.0.0 Memory Leaks?

Matthew Fanto mfanto at gmail.com
Thu Aug 7 19:02:12 UTC 2008


I am seeing memory leaks if the connection to the database fails, due to the
DB being offline. I'm running my app through "Leaks", similar to Valgrind.
I've written a wrapper class around Libpqxx. Am I missing something in
destroying the libpqxx objects?

The following is pseudo-code:

Class DBWrapper {

private:

pqxx::connection *dbconn;


public:

DBWrapper() : dbconn(NULL) { }
~DBWrapper() { delete dbconn }

Connect() { dbconn = new pqxx::connection(connect_string) }

};


I use the class with:

DBWrapper db;
db.Connect();

Note that delete

Here is the call trace for one of the memory leaks:

DBWrapper::Connect()
pqxx:basic_connection<pqxx::connect_director>::basic_connection(char const
*)
pqxx::connection_base::init()
pqxx::connect_direct::do_startconnect(pg_conn*)
pqxx::connectionpolicy::normalconnect(pg_conn*)
PQconnectdb
PQconnectStart
makeEmptyPGconn
malloc

I have verified the destructor is calling "delete dbconn". It's not being
initalized anyway, since the connection is failing.

Am I missing something in destructing the object?

Best,
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://pgfoundry.org/pipermail/libpqxx-general/attachments/20080807/0b5f3448/attachment.html 


More information about the Libpqxx-general mailing list