Re: BUG #16112: large, unexpected memory consumption

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>, ben@lantern.is, pgsql-bugs@lists.postgresql.org
Date: 2019-11-13T17:21:47Z
Lists: pgsql-bugs
Andres Freund <andres@anarazel.de> writes:
> On 2019-11-13 15:50:04 +0100, Tomas Vondra wrote:
>> The attached trivial patch fixes that by adding a pfree() at the end of
>> the function.

> Hm. That's clearly an improvement. But I'm not quite sure it's really
> the right direction. It seems like a bad idea to rely on
> ExecMakeTableFunctionResult() otherwise never leaking any memory.

Considering that ExecMakeTableFunctionResult went from zero pallocs
to one, I don't see a strong reason why it should have bothered with
a private memory context before, nor do I think that's a good
response now.

			regards, tom lane



Commits

  1. Fix transient memory leak for SRFs in FROM.

  2. Fix two memory leaks around force-storing tuples in slots.

  3. Rejigger materializing and fetching a HeapTuple from a slot.