Re: [PATCH v1] fix potential memory leak in untransformRelOptions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH v1] fix potential memory leak in untransformRelOptions
Date
Msg-id 488048.1662052395@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH v1] fix potential memory leak in untransformRelOptions  (Junwang Zhao <zhjwpku@gmail.com>)
Responses Re: [PATCH v1] fix potential memory leak in untransformRelOptions
List pgsql-hackers
Junwang Zhao <zhjwpku@gmail.com> writes:
> I'm a little confused when we should call *pfree* and when we should not.
> A few lines before there is a call *text_to_cstring* in which it invokes
> *pfree* to free the unpacked text [0]. I'm just thinking that since *s* has
> been duplicated, we should free it, that's where the patch comes from.

By and large, the server is designed so that small memory leaks don't
matter: the space will be reclaimed when the current memory context
is deleted, and most code runs in reasonably short-lived contexts.
Individually pfree'ing such allocations is actually a net negative,
because it costs cycles and code space.

There are places where a leak *does* matter, but unless you can
demonstrate that this is one, it's not worth changing.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Jehan-Guillaume de Rorthais
Date:
Subject: [BUG] wrong FK constraint name when colliding name on ATTACH
Next
From: Pavel Stehule
Date:
Subject: Re: Schema variables - new implementation for Postgres 15