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 1o61oI-0002nG-To for pgsql-general@arkaria.postgresql.org; Tue, 28 Jun 2022 03:22:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o61oH-00065l-OM for pgsql-general@arkaria.postgresql.org; Tue, 28 Jun 2022 03:22:41 +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 1o61oH-00065c-El for pgsql-general@lists.postgresql.org; Tue, 28 Jun 2022 03:22:41 +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 1o61oF-0007t9-5Q for pgsql-general@lists.postgresql.org; Tue, 28 Jun 2022 03:22:40 +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 25S3MbC92246457; Mon, 27 Jun 2022 23:22:37 -0400 From: Tom Lane To: Karl Denninger cc: pgsql-general@lists.postgresql.org Subject: Re: Libpq question related to allocated resources In-reply-to: <5cb156e4-0c40-d66e-5fcd-94556f58bb2b@denninger.net> References: <5cb156e4-0c40-d66e-5fcd-94556f58bb2b@denninger.net> Comments: In-reply-to Karl Denninger message dated "Mon, 27 Jun 2022 12:35:24 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2246455.1656386557.1@sss.pgh.pa.us> Date: Mon, 27 Jun 2022 23:22:37 -0400 Message-ID: <2246456.1656386557@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Karl Denninger writes: > But -- I still have a /lot /of memory out on the heap according to > jemalloc stats that is not being deallocated, and what's worse is that > if I rig the code to call PQfinish and then PQconnect once again I get > /even more /imbalanced allocate/free counts (and the memory use in said > buckets to go with them.) Hmmm ... I'm not aware of any memory leaks in libpq, but that doesn't mean there are none. Of course, if you're forgetting to PQclear() some PGresults, that's not libpq's fault ;-). > The obvious question, given the warnings in the FastCGI library: Does > libpq /modify /the process environment? No. At least, I see no setenv() calls in it, and I think that it'd be pretty unfriendly for a library to do that to its host application. > A quick grep implies that indeed it may in > backend/libpq/auth.c at least, backend/libpq is unrelated to interfaces/libpq. (I've seen hints that they arose from a common code base, but if so, that was a few decades and a lot of rewrites ago.) regards, tom lane