Re: Silence resource leaks alerts - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Silence resource leaks alerts
Date
Msg-id Z_ij4o4yZ2zQ1V43@paquier.xyz
Whole thread Raw
In response to Silence resource leaks alerts  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: Silence resource leaks alerts
Re: Silence resource leaks alerts
List pgsql-hackers
On Thu, Apr 10, 2025 at 03:10:02PM -0300, Ranier Vilela wrote:
> While it is arguable that this is a false warning, there is a benefit in
> moving the initialization of the string buffer, silencing the warnings that
> are presented in this case.
>
> 1. pg_overexplain.c
> 2. ruleutils.c

These code paths are far from being critical and the two ones in
ruleutils.c are older, even if it is a practice that had better be
discouraged particularly as initStringInfo() can allocate some memory
for nothing.  So it could bloat the current memory context if these
code paths are repeatedly taken.

FWIW, I'm with these changes to delay these initializations as you are
proposing.  The RMT has a say about such changes post feature-freeze,
though, even if the one in pg_overexplain.c is new to v18.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: merge file_exists_in_directory and _fileExistsInDirectory functions and move into common file dumputils.c
Next
From: "Zhijie Hou (Fujitsu)"
Date:
Subject: Fix replica identity checks for MERGE command on published table.