pgsql: Reduce memory leakage in initdb.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Reduce memory leakage in initdb.
Date: 2023-03-22 18:28:53
Message-ID: E1pf3Ce-004rpK-KK@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2023-03-22 19:33:15 Re: pgsql: Teach verify_heapam() to validate update chains within a page.
Previous Message Tom Lane 2023-03-22 17:49:13 pgsql: Add "-c name=value" switch to initdb.