From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Daniel Gustafsson <daniel@yesql.se>
Cc: wliang@stu.xidian.edu.cn, pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Subject: Re: Report a potential memory leak in setup_config()
Date: Tue, 15 Feb 2022 20:45:46 -0500
Message-ID: <3239746.1644975946@sss.pgh.pa.us> (raw)
In-Reply-To: <20220216012953.6d7bzmsblqou3ru4@alap3.anarazel.de>
References: <64ee7543.20d.17efb1270ca.Coremail.wliang@stu.xidian.edu.cn>
<A7070803-5A15-486E-AE04-ECC13CD10038@yesql.se>
<3052163.1644942806@sss.pgh.pa.us>
<20220216012953.6d7bzmsblqou3ru4@alap3.anarazel.de>
Andres Freund <andres@anarazel.de> writes:
> On 2022-02-15 11:33:26 -0500, Tom Lane wrote:
>> It might be worth trying to knock that down a bit, but I wouldn't
>> start with a one-time leak of 28 bytes. It looks like the biggest
>> offender is that we don't bother trying to reclaim the lines
>> malloc'd by readfile() and replace_token(). Fixing that is *maybe*
>> worth the trouble, but TBH no one has complained about initdb's
>> memory consumption.
> It's a bit insane that we allocate the lines[] quite so many times, when
> processing the same file.
Yeah, I noticed that --- why don't we reuse the array of pointers?
Not sure it'd save much compared to freeing the strings, but it is
mighty low-hanging fruit.
> The replacement patterns either are
> compile time constants which we just should handle in genbki.pl, or have
> exactly 1 replacement....
Mmm, really? I thought most of them were data that we don't know
until initdb runs. Anything that really is known at build time,
sure, genbki.pl ought to take care of.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, daniel@yesql.se, pgsql-bugs@lists.postgresql.org
Subject: Re: Report a potential memory leak in setup_config()
In-Reply-To: <3239746.1644975946@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox