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

From Sasmit Utkarsh
Subject Re: Assitance needed for the resolution of memory leak
Date
Msg-id CAM-5MT0RX8Szzo6JE7FEWWvrt6CzNszWBsJrmDOvmY5=0Wh-Og@mail.gmail.com
Whole thread Raw
In response to Re: Assitance needed for the resolution of memory leak  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Assitance needed for the resolution of memory leak
List pgsql-general
Thanks Tom, It did work, and yeah I do have indentation in my editor, there was some formatting issue due to the copy and paste of the code.
:) 

Regards,
Sasmit Utkarsh
+91-7674022625


On Thu, Oct 12, 2023 at 2:07 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Sasmit Utkarsh <utkarshsasmit@gmail.com> writes:
> Like for an ex: I have provided the test run for a file which has 4
> duplicate entries in the input file and below is the leak reported. I have
> followed
> consistently using PQclear to free all PGresult objects.

No you haven't: you've got two PQexec-something calls and
only one PQclear.  If control reaches here:

> res = PQexec(conn, Command);

that will overwrite your only pointer to the PQexecParams
result, and you won't clear it.

BTW, if this is what your code actually looks like in your editor,
it's no wonder you can't follow its basic control flow.  Indent
according to the brace structure, and your life will get easier.

                        regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Assitance needed for the resolution of memory leak
Next
From: Ron
Date:
Subject: Re: Assitance needed for the resolution of memory leak