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.94.2) (envelope-from ) id 1tWGJE-00FMQD-90 for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2025 14:48:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tWGJD-00H4mf-IW for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Jan 2025 14:48:23 +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.94.2) (envelope-from ) id 1tWGJD-00H4mX-AK for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2025 14:48:22 +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.96) (envelope-from ) id 1tWGJ9-000vEX-2g for pgsql-bugs@lists.postgresql.org; Fri, 10 Jan 2025 14:48:22 +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 50AEmGPM2421470; Fri, 10 Jan 2025 09:48:18 -0500 From: Tom Lane To: 2365868844@qq.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18770: The function 'packGraph ' causes a memory leak. In-reply-to: <18770-895a62c1890d7491@postgresql.org> References: <18770-895a62c1890d7491@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 10 Jan 2025 01:49:08 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2421468.1736520496.1@sss.pgh.pa.us> Date: Fri, 10 Jan 2025 09:48:16 -0500 Message-ID: <2421469.1736520496@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > In line 1965 of the trgm_regexp.c file > 1965: arcs = (TrgmPackArcInfo *) > 1966: palloc(sizeof(TrgmPackArcInfo) * trgmNFA->arcsCount); > The memory requested 'arcs' was not freed. This is not a bug, unless you can show that the memory is allocated in a long-lived context that won't get freed reasonably soon. We generally assume that letting memory context cleanup recover memory is both faster and more oversight-proof than retail pfree calls. In this particular case, it looks to me like the memory will come from the temp context made by createTrgmNFA, and therefore will be freed before that returns. regards, tom lane