Re: pg_upgrade: fix memory leak in SLRU I/O code

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade: fix memory leak in SLRU I/O code
Date: 2026-02-05 05:49:53
Message-ID: 5AF72017-4DBE-4837-BA50-54C3B0B8542E@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Feb 5, 2026, at 13:28, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Thu, Feb 05, 2026 at 01:02:08PM +0800, Chao Li wrote:
>> My concern is more about the pattern: freeing the container
>> structure while leaving its members allocated. That feels
>> inconsistent and potentially confusing to readers. Either owning
>> objects should be fully freed, or not freed at all, but partial
>> freeing doesn’t seem like a great precedent. I’m not sure that’s a
>> pattern we want to encourage in PG code.
>
> For one-time allocations that are freed once we exit the binary, I
> would not have bothered about freeing the state,

Exactly. In this case, memory leaking is not a problem at all. My thinking was that once we do decide to free the top-level object, it feels more consistent and less surprising to also free what it owns, even if the lifetime is effectively the whole process. It’s less about resource pressure and more about keeping the ownership model clear for future readers and maintenance.

TBH, I’ve been very careful about judging whether a memory-related issue is really worth patching, as I asked you about this before. I think I used the wrong subject line here, the point isn’t about a memory leak at all.

I understand the trade-off, and I’m happy to drop this if the consensus is that it’s not worth touching.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2026-02-05 06:09:17 Re: Convert NOT IN sublinks to anti-joins when safe
Previous Message Nikolay Samokhvalov 2026-02-05 05:41:01 Re: Add --system-identifier / -s option to pg_resetwal