Re: Is there a memory leak in commit 8561e48?

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Michael Paquier <michael(at)paquier(dot)xyz>, "jian(dot)long(at)i-soft(dot)com(dot)cn" <jian(dot)long(at)i-soft(dot)com(dot)cn>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Is there a memory leak in commit 8561e48?
Date: 2018-05-02 16:14:51
Message-ID: 4ab2aa26-5166-1a35-b89b-c5d73bf565b9@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 5/1/18 11:42, Tom Lane wrote:
> Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
>> The memory leak can be fixed by adding a pfree().
>
> That seems like an odd way to approach this. Why not just remove the
> reset of _SPI_stack and _SPI_stack_depth, so as to subtract code rather
> than adding it --- that is, make it actually work like you mistakenly
> thought it did? If we're going to keep the stack in TopMemoryContext,
> there's no need to thrash it on every transaction.

Yes, that seems attractive.

Are we concerned about the case where someone runs a very deeply nested
SPI setup once in a session, creating a large stack allocation, which
then persists for the rest of the session?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2018-05-02 16:26:31 Re: doc fixes: vacuum_cleanup_index_scale_factor
Previous Message Peter Geoghegan 2018-05-02 16:14:33 Re: Sort performance cliff with small work_mem