pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reduce memory leakage in initdb.
Date: Wed, 22 Mar 2023 18:28:53 +0000
Message-ID: <E1pf3Ce-004rpK-KK@gemulon.postgresql.org> (raw)

Reduce memory leakage in initdb.

While testing commit 3e51b278d, I noted that initdb leaks about a
megabyte worth of data due to the sloppy bookkeeping in its
string-manipulating code.  That's not a huge amount on modern machines,
but it's still kind of annoying, and it's easy to fix by recognizing
that we might as well treat these arrays of strings as
modifiable-in-place.  There's no caller that cares about preserving
the old state of the array after replace_token or replace_guc_value.

With this fix, valgrind sees only a few hundred bytes leaked during
an initdb run.

Discussion: https://postgr.es/m/2844176.1674681919@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4fe2aa7656dce2bd31d4807a6843ff495b9deb80

Modified Files
--------------
src/bin/initdb/initdb.c | 87 +++++++++++++++++++------------------------------
1 file changed, 34 insertions(+), 53 deletions(-)



Message-ID: <E1pf3Ce-004rpK-KK@gemulon.postgresql.org>
Permalink:  ../E1pf3Ce-004rpK-KK@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pf3Ce-004rpK-KK@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Reduce memory leakage in initdb.
  In-Reply-To: <E1pf3Ce-004rpK-KK@gemulon.postgresql.org>

* 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