Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5zxC-0007zv-OU for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Mar 2019 21:37:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5zxB-0005bs-2b for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Mar 2019 21:37:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5zxA-0005bl-P9 for pgsql-bugs@lists.postgresql.org; Mon, 18 Mar 2019 21:37:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5zx3-0000Gw-Vp for pgsql-bugs@lists.postgresql.org; Mon, 18 Mar 2019 21:37:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x2ILbfLs016693; Mon, 18 Mar 2019 17:37:41 -0400 From: Tom Lane To: Andres Freund cc: Jeff Janes , Matthias Otterbach , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15700: PG 10 vs. 11: Large increase in memory usage when selecting BYTEA data (maybe memory leak) In-reply-to: <13467.1552942521@sss.pgh.pa.us> References: <15700-8c408321a87d56bb@postgresql.org> <16717.1552926811@sss.pgh.pa.us> <4ef5f38d5710c4d5c289537c588c7335@otterbach.eu> <13467.1552942521@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 18 Mar 2019 16:55:21 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <16682.1552945040.0@sss.pgh.pa.us> Date: Mon, 18 Mar 2019 17:37:41 -0400 Message-ID: <16692.1552945061@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16682.1552945040.1@sss.pgh.pa.us> I wrote: > Jeff Janes writes: >> The culprit is f2dec34e19d3969ddd6. > Hmm. I bet problem is that the buf isn't being freed in > printtup_shutdown. Yup; the attached fixes it. Will push after a bit more testing. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="fix-printtup-leak.patch"; charset="us-ascii" Content-ID: <16682.1552945040.2@sss.pgh.pa.us> Content-Description: fix-printtup-leak.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/access/common/printtup.c b/src/backend/access/com= mon/printtup.c index e4ee5c9..5eb928b 100644 *** a/src/backend/access/common/printtup.c --- b/src/backend/access/common/printtup.c *************** printtup_create_DR(CommandDest dest) *** 91,96 **** --- 91,97 ---- */ self->sendDescrip =3D (dest =3D=3D DestRemote); = + self->buf.data =3D NULL; self->attrinfo =3D NULL; self->nattrs =3D 0; self->myinfo =3D NULL; *************** printtup_shutdown(DestReceiver *self) *** 547,552 **** --- 548,557 ---- if (myState->tmpcontext) MemoryContextDelete(myState->tmpcontext); myState->tmpcontext =3D NULL; + = + if (myState->buf.data) + pfree(myState->buf.data); + myState->buf.data =3D NULL; } = /* ---------------- ------- =_aaaaaaaaaa0--