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.96) (envelope-from ) id 1vsQ70-000G3Z-02 for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Feb 2026 18:47:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsQ6z-00BTt8-14 for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Feb 2026 18:47:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vsQ6z-00BTsy-0F for pgsql-bugs@lists.postgresql.org; Tue, 17 Feb 2026 18:47:53 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vsQ6x-00000001Ey0-0nZx for pgsql-bugs@lists.postgresql.org; Tue, 17 Feb 2026 18:47:52 +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 61HIlnqc1881735; Tue, 17 Feb 2026 13:47:49 -0500 From: Tom Lane To: Matt Carter cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed In-reply-to: References: <19411-0440c8897a04b638@postgresql.org> <1702505.1771347709@sss.pgh.pa.us> Comments: In-reply-to Matt Carter message dated "Tue, 17 Feb 2026 17:54:17 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1881733.1771354069.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 17 Feb 2026 13:47:49 -0500 Message-ID: <1881734.1771354069@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Matt Carter writes: > Tom Lane wrote: >> I think there are way too many moving parts here, and too few configura= tion details, >> to allow assigning blame confidently. > Thank you for taking the time to test this and for the feedback. Your C= test showing no leak suggests the issue is specific to how psycopg2 uses = libpq, not libpq itself. I apologize for not including enough environment= al details. I used Kerberos/GSSAPI with SSL (TLS 1.2 connections). My co= nnection string was: "postgresql://hostname/database" (no password, Kerber= os auth). > Your mention of "years ago libpq did leak memory while using GSSAPI encr= yption" is interesting because we ARE using GSSAPI/Kerberos authentication= . Interesting. I wondered about GSSAPI, but spinning up such an environment is more work than I wanted to do on speculation. > I can test with non-GSSAPI authentication to try to isolate that variabl= e. I can also create a pure psycopg2 reproducer (without SQLAlchemy). I = can also test whether disabling GSSAPI encryption (but keeping GSSAPI auth= ) changes the behavior. Would testing with GSSAPI authentication help nar= row this down? I can also report this to the psycopg2 project if you think= it's their issue. Please try varying the connection type and encryption. I do suspect this may be psycopg2's fault, but we lack enough data to pin blame as yet. regards, tom lane