Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qqfyO-000Wls-Jq for pgsql-general@arkaria.postgresql.org; Wed, 11 Oct 2023 20:38:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qqfxM-000XZ3-Ki for pgsql-general@arkaria.postgresql.org; Wed, 11 Oct 2023 20:37:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qqfxM-000XYv-9r for pgsql-general@lists.postgresql.org; Wed, 11 Oct 2023 20:37:24 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qqfxG-0000qQ-Uo for pgsql-general@lists.postgresql.org; Wed, 11 Oct 2023 20:37:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 39BKbFJO881281; Wed, 11 Oct 2023 16:37:15 -0400 From: Tom Lane To: Sasmit Utkarsh cc: Adrian Klaver , pgsql-general@lists.postgresql.org Subject: Re: Assitance needed for the resolution of memory leak In-reply-to: References: Comments: In-reply-to Sasmit Utkarsh message dated "Thu, 12 Oct 2023 01:56:20 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <881279.1697056635.1@sss.pgh.pa.us> Date: Wed, 11 Oct 2023 16:37:15 -0400 Message-ID: <881280.1697056635@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sasmit Utkarsh 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