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 1qqjDi-000lPB-Sx for pgsql-general@arkaria.postgresql.org; Thu, 12 Oct 2023 00:06:30 +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 1qqjCg-001cXC-Vx for pgsql-general@arkaria.postgresql.org; Thu, 12 Oct 2023 00:05:27 +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 1qqjCg-001cX3-9K for pgsql-general@lists.postgresql.org; Thu, 12 Oct 2023 00:05:27 +0000 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qqjCd-0002EX-5h for pgsql-general@lists.postgresql.org; Thu, 12 Oct 2023 00:05:25 +0000 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-5a4c073cc06so13514737b3.1 for ; Wed, 11 Oct 2023 17:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697069122; x=1697673922; darn=lists.postgresql.org; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=uZrYlWnwFYmm3vIbv0s48xjYVjmbKWCcWDfD3c/UxSg=; b=ipOEgnzCrRC2SanrepPtiofLI+10Js1y7ydUx7xj0H4AvUXe44griEldIMspGlUWJ+ Ll0UnWSFicRQ4UybR/EC+oWkwaYhofE/MfX0FNVngYCf/NYuZQguU2K9EFncV2pc5VC0 ut4gWCF93PqnMGKkjYaoS9gbM7wPMymk3DQoXXwvPiKxg2NZpXprnn0eQuaoDLM44K+9 V3SLb0r/Z9WPLQimjTLw7o8Y4vGXF0yz5MZL760PY4H49Dwpg21JlclYDUdys8s4UahU YGJdCoWYiz5IX+jdH+hXwvN/k7jmWkWSSY+Dndd/q16eRAi/N22Xd6zlr+Bx6kfEtn/J Vpsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697069122; x=1697673922; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=uZrYlWnwFYmm3vIbv0s48xjYVjmbKWCcWDfD3c/UxSg=; b=L45uE9wpTfL0741tZdiQuj6KWgd5aO7pG+3YtNan5mv8lkZiYIcv39wf0pGwwbLRjC YaLWSrJG44E7w7D+RjLaotqC4imZZKwymTMUJB1i8tna9q56R18EbEDf1sR4w7La/UnG OmCHpdgXu1CL1VwJHjW0ass8LQ40CjHAORb/ExrJzAcrrhMBkegJvRR8ILeeC97WxUJ1 uuK98mjMae6MPOV1CU7jUNZ3Cca2cwejnoxFWwkIPU9o+zx7noMIYcg+MnTPVAiZxsBv +WUQFjyO6goiG+vQ56B8StILrxdYWvp0atEoQ86mfBPlP5jrTQrSkCd3Crbo8kF3I2QO k7Mg== X-Gm-Message-State: AOJu0Yz9sRxEqBl+Mh2r9cf4/2NgY6bVKMICKMD4NZbIu39Q8V7hZLZC fTGLn9vfnHedVW1WkBFoOxIwgRq15cM= X-Google-Smtp-Source: AGHT+IF1R283LgwG1qZQccINoEX+uo+FR3KCOWQH1vD3M8GdZtGPqX3Amm55uPWtgLUD+yFHWCnvLg== X-Received: by 2002:a0d:dbcc:0:b0:5a7:fc15:3439 with SMTP id d195-20020a0ddbcc000000b005a7fc153439mr212434ywe.22.1697069121552; Wed, 11 Oct 2023 17:05:21 -0700 (PDT) Received: from ?IPV6:2600:1700:bd2c:b810:9c07:69c3:3e12:3c8? ([2600:1700:bd2c:b810:9c07:69c3:3e12:3c8]) by smtp.googlemail.com with ESMTPSA id g137-20020a0ddd8f000000b005a247c18403sm702251ywe.37.2023.10.11.17.05.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Oct 2023 17:05:21 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------rABJWjdprZPq7CnHfIZ5Y1Uu" Message-ID: <6316561b-8dc5-c870-83d5-1efc9217178e@gmail.com> Date: Wed, 11 Oct 2023 19:05:20 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: Assitance needed for the resolution of memory leak Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <881280.1697056635@sss.pgh.pa.us> From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------rABJWjdprZPq7CnHfIZ5Y1Uu Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit That's why you /attach/ files, not paste text. On 10/11/23 16:19, Sasmit Utkarsh wrote: > 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 wrote: > > 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 > -- Born in Arizona, moved to Babylonia. --------------rABJWjdprZPq7CnHfIZ5Y1Uu Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit That's why you attach files, not paste text.

On 10/11/23 16:19, Sasmit Utkarsh wrote:
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

--
Born in Arizona, moved to Babylonia.
--------------rABJWjdprZPq7CnHfIZ5Y1Uu--