Re: Curing plpgsql's memory leaks for statement-lifespan values

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Curing plpgsql's memory leaks for statement-lifespan values
Дата
Msg-id CAMsr+YGwc0xte1wp_aqBFiWbXvf=tEG4U-JC8yZWSzsjQv5-Ug@mail.gmail.com
обсуждение исходный текст
Ответ на Curing plpgsql's memory leaks for statement-lifespan values  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Curing plpgsql's memory leaks for statement-lifespan values  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers

On 22 July 2016 at 07:02, Tom Lane <tgl@sss.pgh.pa.us> wrote:
In
https://www.postgresql.org/message-id/tencent_5C738ECA65BAD6861AA43E8F@qq.com
it was pointed out that you could get an intra-function-call memory leak
from something like

        LOOP
          BEGIN
            EXECUTE 'bogus command';
          EXCEPTION WHEN OTHERS THEN
          END;
        END LOOP;

...
 

Another answer is to invent a third per-function memory context intended
to hold statement-lifespan variables.


I've wanted this in the past and been surprised we don't have it, so +1 from me. 

I don't think a few MemoryContextAlloc's are too ugly.

I suggest that in cassert builds, or maybe just CACHE_CLOBBER_ALWAYS, the context is reset after each call even when not cleaning up after an error. That'll help catch mistakes and leaks.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Password identifiers, protocol aging and SCRAM protocol
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: Curing plpgsql's memory leaks for statement-lifespan values