| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Extended Statistics set/restore/clear functions. |
| Date: | 2026-01-19 23:23:38 |
| Message-ID: | aW68-vC2fkQ54pLC@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Jan 19, 2026 at 04:56:25PM +0800, Chao Li wrote:
> Should tuples returned by SearchSysCacheCopy1() always be explicitly
> freed with heap_freetuple()? I’ve long had the understanding that
> the answer is “yes”.
>
> However, recently I’ve seen some patches addressing apparent memory
> leaks deemed unnecessary on the grounds that the surrounding memory
> context would clean things up anyway. That made me unsure whether
> the same reasoning is considered acceptable for tuples returned by
> SearchSysCacheCopy1(), or whether the expectation is still that
> callers should free them explicitly.
My guess is that it depends on the context where a given function is
called. If for example SearchSysCacheCopy1() is used in something in
a tight loop, freeing memory is justified to me. A SQL function would
have its execution memory context pretty quickly, though, so a free()
would make less sense. So there is no strict rule on the matter, one
or other other may make more sense.
--
Michael
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-01-19 23:33:49 | Some cleanup of pg_stat_statements tests |
| Previous Message | Michael Paquier | 2026-01-19 23:21:19 | Re: Add WALRCV_CONNECTING state to walreceiver |