Re: pg_upgrade: fix memory leak in SLRU I/O code - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: pg_upgrade: fix memory leak in SLRU I/O code
Date
Msg-id aYQefwYTPypf5yZU@paquier.xyz
Whole thread Raw
In response to Re: pg_upgrade: fix memory leak in SLRU I/O code  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: pg_upgrade: fix memory leak in SLRU I/O code
List pgsql-hackers
On Thu, Feb 05, 2026 at 12:02:51PM +0800, Chao Li wrote:
> Thank you very much for the review. Yes, the leak itself is tiny,
> the main point for me is that the memory owned by the struct members
> is not freed, which can be a bit confusing for code readers. As for
> the change from pstrdup() to pg_strdup(), that felt too trivial to
> justify a separate patch, so I took this as an opportunity to clean
> it up at the same time.

Does it really matter memory-wise?  Even in the case of state->fn,
SlruReadSwitchPageSlow() and SlruWriteSwitchPageSlow() make sure to
free it before switching to a new segment to process, and these state
allocations are done once.  Well, okay, twice as of the members *and*
the offsets, but the logic as written is not going to bloat memory
with a short loop execution.

In short, I see nothing worth changing.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: logical apply worker's lock waits in subscriber can stall checkpointer in publisher
Next
From: Shinya Kato
Date:
Subject: Re: Report oldest xmin source when autovacuum cannot remove tuples