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 1u8nJH-00BirF-JL for pgsql-general@arkaria.postgresql.org; Sat, 26 Apr 2025 21:43:43 +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 1u8nJE-0074eg-Iw for pgsql-general@arkaria.postgresql.org; Sat, 26 Apr 2025 21:43:41 +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 1u8nJE-0074eK-6B for pgsql-general@lists.postgresql.org; Sat, 26 Apr 2025 21:43:41 +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.96) (envelope-from ) id 1u8nJC-0027Pd-2z for pgsql-general@lists.postgresql.org; Sat, 26 Apr 2025 21:43:40 +0000 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-7080dd5f9f1so24079297b3.0 for ; Sat, 26 Apr 2025 14:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745703818; x=1746308618; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=723ayMEjH9q77ycbxaMPkCLlHMElG8BfgKa/wbmt8eA=; b=GAeASlaTUoS1RdodBKBQdgsR5v6fnbdLCo9LDRbG4Rt2o5qYcgxEMaGkhctWaht3tN Tu3raV5P9XWNbIw0oXjKfmjbkmsutuKzPy3AmAKB2nbNe7PxZsTlBK9Y2KXIvyng4At0 fD/VtpGDTjRKywosofl6FmA8iB4S62PayIzOadsxnRt9Qt5MM92p1FQYQm+hnEv0Pmpx Fex9vU2dvPBTzZ2y1T+pY6lZNnmLHjKFJFsBAhrgs4bZyY90Z5I7g14RfZrbdf/w+ANB iH0CndS+KQcHLA4fhOnDYKgBlXRc4hRaypylNCrL1CHCuju7suv7cCcITNJ9YTWdPpuo 0e3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745703818; x=1746308618; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=723ayMEjH9q77ycbxaMPkCLlHMElG8BfgKa/wbmt8eA=; b=Ug6QOTUKIlY1qXvum8a2Eir5jYvpI4jc12FRrdnYRy92yAZtV2nihsMkRsYly2uqwq j76yy+Kdkf/V8vALslyrrF/qF4vXwyHOjsOoloeP3dRsPQo9Pfc74fPZVVn4peokHj+h Q4yJW1W8ZAgRPtlOO9CJf4vxDbkCmPncuX7Te8NnefhgerAr1E06sLomSPR5V1bFzgZc rKkSNudPYQFsKNkrVHiN8MpMQpL9KZaILT/401yBrNdcbRhRWNSozgCqzMzCpZYWeHJ2 Rcg8qX6Z2c3ImVImoPQQNTaFjH99SE5jdYYpz46iKHN0oW6VvjoKb8ckUp8Uj5VZJazc Q7mA== X-Forwarded-Encrypted: i=1; AJvYcCXcKC5QQMcxa/Wjnk4Z99ub7AmIyXfXBiqmBRqk7DWGN+u0XbKA1ACPXqrTQf8TAbYL6nTq6nW26mmirizR@lists.postgresql.org X-Gm-Message-State: AOJu0YxO8m69bKFx8YZGmef2AWb45BWuXS89fTla7WyFciNgM57R3zKa cGDOd5Dt8ZHEdSMWJV1ShhXr7KPvnLvMs6CzlBfeZbQ+2e2EhpTasmfl+3SfafU0h8TGD7ePtMG b1E6FKkvsXMUZh9Eha2cxK2cMPpYHZBo7 X-Gm-Gg: ASbGncuMZvw8bGgcTf16PVcCksXrBuBiA/ChS5jkEGuwhJo/4Fk8oVJEAS6+RJBGfoB 4xi1WJlT7G56hjzPhWEm6LjDkrffHZA8Fo6XFTplGFlaoosqi/TesSWwphFSuUcaS1+7XfKZVnM x2bWGafE4fhaBP12Egn763KXj7N/xkaxWR+VIu7dXuVrFZrl62oNy1CvaN X-Google-Smtp-Source: AGHT+IF+K8qTbIr6/7eiEovKMZV18QpC4woivOghKuEPsGe45ykQ2gMZ7nl31Zqu72e5tPoLLyi7/cqFxTtqg5e1JDE= X-Received: by 2002:a05:690c:39b:b0:6fe:b761:5798 with SMTP id 00721157ae682-70854128ec7mr91973967b3.21.1745703818486; Sat, 26 Apr 2025 14:43:38 -0700 (PDT) MIME-Version: 1.0 References: <0a2be546e57d6088acf734f8d6a308a984e7171b.camel@cybertec.at> <132172.1745703297@sss.pgh.pa.us> In-Reply-To: <132172.1745703297@sss.pgh.pa.us> From: Igor Korot Date: Sat, 26 Apr 2025 16:43:27 -0500 X-Gm-Features: ATxdqUHPYkXx8hr8ioUVgEd5iUFnUabRfXFXwwJxDa7-i3Ts9YYmgVWIr4aTRiY Message-ID: Subject: Re: How to properly fix memory leak To: Tom Lane Cc: Laurenz Albe , "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000fbed390633b55724" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000fbed390633b55724 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Tom, On Sat, Apr 26, 2025 at 4:34=E2=80=AFPM Tom Lane wrote: > Igor Korot writes: > >>>> auto temp1 =3D m_pimpl->m_myconv.from_bytes( PQgetvalue( > >>>> res, i, 1 ) ); > >>>> m_tablespaces.push_back( temp1 ); > > I would imagine that from_bytes() is producing a malloc'd > string. Which part of this is responsible for seeing that > that gets freed? No other places produces memory leak. And I use this function quite extensively=E2=80=A6 Thank you. > > regards, tom lane > --000000000000fbed390633b55724 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, Tom,

On Sat, Apr 26, 2025 a= t 4:34=E2=80=AFPM Tom Lane <tgl@sss= .pgh.pa.us> wrote:
Igor Kor= ot <ikorot01@gma= il.com> writes:
>>>> auto temp1 =3D m_pimpl->m_myconv.from_bytes( PQgetvalue= (
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0res, i, 1 ) )= ;
>>>> m_tablespaces.push_back( temp1 );

I would imagine that from_bytes() is producing a malloc'd
string.=C2=A0 Which part of this is responsible for seeing that
that gets freed?

= No other places produces memory leak.
And I use this= function quite extensively=E2=80=A6

Thank you.



=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane
--000000000000fbed390633b55724--