From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sasmit Utkarsh <utkarshsasmit@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Assitance needed for the resolution of memory leak
Date: Wed, 11 Oct 2023 16:37:15 -0400
Message-ID: <881280.1697056635@sss.pgh.pa.us> (raw)
In-Reply-To: <CAM-5MT1bTbO_sCUVXiXoTehUfrgYVc8UHmNANLU8+feczK=xew@mail.gmail.com>
References: <CAM-5MT368yobLg+tscP0c8-zBEjymL8_OS+1GvDX5wNNcebvmA@mail.gmail.com>
<f5471979-ee1b-4391-b324-fcc66cba7e06@aklaver.com>
<CAM-5MT1bTbO_sCUVXiXoTehUfrgYVc8UHmNANLU8+feczK=xew@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, utkarshsasmit@gmail.com, adrian.klaver@aklaver.com
Subject: Re: Assitance needed for the resolution of memory leak
In-Reply-To: <881280.1697056635@sss.pgh.pa.us>
References: <CAM-5MT368yobLg+tscP0c8-zBEjymL8_OS+1GvDX5wNNcebvmA@mail.gmail.com> <f5471979-ee1b-4391-b324-fcc66cba7e06@aklaver.com> <CAM-5MT1bTbO_sCUVXiXoTehUfrgYVc8UHmNANLU8+feczK=xew@mail.gmail.com> <881280.1697056635@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox