Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQZVT-0002G6-Vq for pgsql-general@arkaria.postgresql.org; Fri, 10 Feb 2023 19:56:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pQZVS-00080C-KQ for pgsql-general@arkaria.postgresql.org; Fri, 10 Feb 2023 19:56:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQZVS-000803-8p for pgsql-general@lists.postgresql.org; Fri, 10 Feb 2023 19:56:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQZVO-0001y7-J5 for pgsql-general@postgresql.org; Fri, 10 Feb 2023 19:56:25 +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 31AJuLdT086421; Fri, 10 Feb 2023 14:56:21 -0500 From: Tom Lane To: =?UTF-8?Q?Jon_Erdman?= cc: =?UTF-8?Q?pgsql-general=40postgresql=2Eorg?= Subject: Re: valgrind a background worker In-reply-to: <010101863c80f496-4bebe323-cb8a-4ac6-b1ae-b197a7fc70ba-000000@us-west-2.amazonses.com> References: <4076400.1676041432@sss.pgh.pa.us> <010101863c80f496-4bebe323-cb8a-4ac6-b1ae-b197a7fc70ba-000000@us-west-2.amazonses.com> Comments: In-reply-to =?UTF-8?Q?Jon_Erdman?= message dated "Fri, 10 Feb 2023 18:05:29 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <86419.1676058981.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 10 Feb 2023 14:56:21 -0500 Message-ID: <86420.1676058981@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?UTF-8?Q?Jon_Erdman?=3D writes: > I=E2=80=99m suspecting that the leak might be coming from initStringInfo= (), as I see a palloc() in there and no associated pfree() in my backgroun= d worker=E2=80=99s code, but looking at the elog backend code, it looks li= ke maybe you only have to explicitly free buf if you relocate it larger? Usually it's more like "you need to pfree if you allocated in a long-lived memory context". elog is working in ErrorContext which it expects will be reset when the dust settles. regards, tom lane