Re: Help needed for the resolution of memory leak - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Help needed for the resolution of memory leak
Date
Msg-id CAHyXU0wmjF=3qmR5NZtpZMTKM958Nhsb022Yz0TGHFMO5VH=9w@mail.gmail.com
Whole thread Raw
In response to Help needed for the resolution of memory leak  (Sasmit Utkarsh <utkarshsasmit@gmail.com>)
List pgsql-general
On Mon, Jan 15, 2024 at 11:32 AM Sasmit Utkarsh <utkarshsasmit@gmail.com> wrote:
Hi Team,

I am trying to test a code which basically tries to read some data from postgresql db in a loop through a function SQL_get_tpf_rw() whose definition and other details are shared in the attached file along with the memory leak report resulted during testing. Could you let me know if i missed calling  anywhere PQclear()
in SQL_get_tpf_rw() which resulted in the below .

Last few lines from the report


yep:  for example,

      if (PQresultStatus(res) != PGRES_TUPLES_OK)           {                LOG_ERROR("SELECT failed: %s", PQerrorMessage(conn));		LOG_DEBUG("ROLLBACK TRANSACTION AND CHAIN");		res = PQexec(conn,"ROLLBACK TRANSACTION AND CHAIN");		LOG_ERROR("INVALID_FILE_ADDRESS %08X",fa);		rc = ERR_INVALID_FILE_ADDRESS;

See highlighted bits.  You're reusing the res object before clearing it.  there may be other cases, but this jumped off the page.

merlin

pgsql-general by date:

Previous
From: Justin Clift
Date:
Subject: Re: Moving to Postgresql database
Next
From: Lan Xu
Date:
Subject: Re: Help with "Create Extension unaccent"