Re: Fix memory leak in postmasterMain

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Henrik TJ <henrik(at)0x48(dot)dk>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix memory leak in postmasterMain
Date: 2026-04-22 15:29:29
Message-ID: CAHGQGwEn3oEad-wR1XoEbe1R-pB1EOycRKjEj+5Pp38mjgiF+Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 22, 2026 at 3:46 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> From my experience, most of the time the postmaster is started with -D. On Linux and macOS, that path can be quite long, PATH_MAX is often 4096 on many Unix-like systems, and I am not sure about Windows. So I think this leak is worth fixing.

We can also free()/pfree() userDoption in postgres.c and bootstrap.c?

Since userDoption typically uses only a small amount of memory, I'm not sure
this patch provides much practical benefit from a memory-leak perspective.
So I don't think it needs to be backpatched to the stable branches.

OTOH, if it helps keep Valgrind quiet for userDoption, I may be ok with
applying it to master.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-04-22 16:03:22 Re: StringInfo fixes, v19 edition. Plus a few oddities
Previous Message Fabrízio de Royes Mello 2026-04-22 14:21:56 Re: RFC: pg_stat_logmsg