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 1h60G2-0000SR-RF for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Mar 2019 21:57:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h60G1-0001a6-9u for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Mar 2019 21:57:21 +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 1h60Fz-0001ZK-K3 for pgsql-bugs@lists.postgresql.org; Mon, 18 Mar 2019 21:57:21 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h60Fw-0000jH-9k for pgsql-bugs@lists.postgresql.org; Mon, 18 Mar 2019 21:57:18 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id CEAB53E1A; Mon, 18 Mar 2019 17:57:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 18 Mar 2019 17:57:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=OE4a0V2cYHqkPf+HUdewviSMnwf DCPdhRPxB6ADg/w0=; b=pzNwDDTNfig1zHfJ07dyxiEhSdQ9IYae0pIU5nJnpb/ kjmb2yezEfuMx93zG61JjClakDfHLd9PS3ICk7+euALjlUJIBXyE8rzuYKMR3XzE KJ5F8Rxn3iQ3ddxnuLh2DTgfjvhmGjLeo92EVys4zf+X+ViTE9APt4c4f3pPCcOY 4a0VYqvdXE13ZmPZbLESFMl8DibNYeVwVkuS8LS1MX2pJob2Rz6pwl5z+WQ0BRTH m+vhls2fuFFsoxARuvOw+2DVtEJpdx7ZvhjJhQbbKnhQFaB20ZuisgoRktBdqssY auSPlawMvOTXBKMxv1YoU3Edp5gvKCYUd4CG0nkbE9Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=OE4a0V 2cYHqkPf+HUdewviSMnwfDCPdhRPxB6ADg/w0=; b=chPStKE88sgceAZntY68AR deLCYXTIaM0ynd6ROlT0Nvc0cUUBnFTqX873R9WujMX/8ZZoj2Kg2M4b8WF3D+3N 3BxhBSGADSbUpFAEogHYzkuH6LkrN7EKN/PReSFqB51KJ8PDxro1UjNlGUp5A0+2 Jt+O/23D+MD1IcpaPJNC9RTxcUU3KZZSL2fryhZIVlp0NN8km5GFNLIzVgPB71G7 3mfY2RLNdD+ioAwBPrk1rdqdPGu8mhBX9S30jWzTLPWIHX7JEeJEmupkeiN/sVzI SZGZKyVcGEvq3vmrHAJAT4J5M/6HXFwRPyImu3XfqPmNxTBLq6IDGnVKHYFS3q/Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddriedugdduheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucfkpheple ekrddvuddtrddugedtrddujedunecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgv shesrghnrghrrgiivghlrdguvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 333DFE4549; Mon, 18 Mar 2019 17:57:12 -0400 (EDT) Date: Mon, 18 Mar 2019 14:57:10 -0700 From: Andres Freund To: Tom Lane 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) Message-ID: <20190318215710.f6balpny456kink2@alap3.anarazel.de> References: <15700-8c408321a87d56bb@postgresql.org> <16717.1552926811@sss.pgh.pa.us> <4ef5f38d5710c4d5c289537c588c7335@otterbach.eu> <13467.1552942521@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13467.1552942521@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-03-18 16:55:21 -0400, Tom Lane wrote: > Jeff Janes writes: > > The culprit is f2dec34e19d3969ddd6. > > Hmm. I bet problem is that the buf isn't being freed in > printtup_shutdown. That's indeed part of it, and there's very little reason (besides there not being a convenient function for it, but it's obviously trivial to open code) to not free it. This specific issue can trivially resolved by adding something like /* free memory allocated by initStringInfo */ if(myState->buf.data) pfree(myState->buf.data); myState->buf.data = NULL; to printtup_shutdown(). I'm inclined to just leave it open coded for now. But are we actually prepared to assume that nothing ever leaks in receivers? That's, as far as I can tell, not a documented assumption. What we're getting here is a stream of: 2019-03-18 14:47:46.159 PDT [30035][3/4] LOG: duration: 0.269 ms parse : SELECT b FROM public.a 2019-03-18 14:47:46.159 PDT [30035][3/4] LOG: duration: 0.235 ms bind /C_1: SELECT b FROM public.a 2019-03-18 14:47:50.705 PDT [30035][3/4] LOG: duration: 4545.495 ms execute /C_1: SELECT b FROM public.a 2019-03-18 14:48:01.126 PDT [30035][3/4] LOG: duration: 9613.291 ms execute fetch from /C_1: SELECT b FROM public.a 2019-03-18 14:48:06.488 PDT [30035][3/4] LOG: duration: 4564.857 ms execute fetch from /C_1: SELECT b FROM public.a 2019-03-18 14:48:11.700 PDT [30035][3/4] LOG: duration: 4449.060 ms execute fetch from /C_1: SELECT b FROM public.a (ignore the timing, I had a debugger attached) So we're assuming that all dest receivers never leak. We're also assuming that we don't leak into MessageContext over such cycles, which seems wrong. At the very least things like errdetail_params() are happy to leak into MessageContext. Greetings, Andres Freund