On Tue, Jan 10, 2012 at 6:48 PM, Michael P. Soulier <michael_soulier@xxxxxxxxx> wrote: > res = PQexec(conn, "BEGIN"); > if (PQresultStatus(res) != PGRES_COMMAND_OK) > { > fprintf(stderr, "DB: BEGIN command failed: %s", PQerrorMessage(conn)); > PQclear(res); > exit_nicely(conn); > } > > res = PQexec(conn, commandbuf); > if (PQresultStatus(res) != PGRES_COMMAND_OK) > { > fprintf(stderr, "DB: UPDATE command failed: %s", PQerrorMessage(conn)); > PQclear(res); > exit_nicely(conn); > } > > /* end the transaction */ > res = PQexec(conn, "END"); > PQclear(res); You're missing 2 PQclear() calls on success. http://www.postgresql.org/docs/devel/static/libpq-exec.html#LIBPQ-EXEC-MAIN PQclear Frees the storage associated with a PGresult. Every command result should be freed via PQclear when it is no longer needed. void PQclear(PGresult *res); You can keep a PGresult object around for as long as you need it; it does not go away when you issue a new command, nor even if you close the connection. To get rid of it, you must call PQclear. Failure to do this will result in memory leaks in your application. -- Simon Riggs http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general