Re: MemoryContextCreate change in PG 11 how should contexts be created

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: MemoryContextCreate change in PG 11 how should contexts be created
Дата
Msg-id 30424.1513695654@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: MemoryContextCreate change in PG 11 how should contexts be created  (Paul Ramsey <pramsey@cleverelephant.ca>)
Ответы Re: MemoryContextCreate change in PG 11 how should contexts be created  (Paul Ramsey <pramsey@cleverelephant.ca>)
Список pgsql-hackers
Paul Ramsey <pramsey@cleverelephant.ca> writes:
> Our use of MemoryContextCreate is solely in order to get use
> MemoryContextDelete as a callback so that, at the end of a statement,
> we can clean up externally allocated memory that we're holding in a
> cache. If we had some other callback to use for "the statement is
> complete, you can clean up now", we could avoid all this mucking
> around with raw MemoryContexts entirely. The MemoryContext trick/hack
> is very old, perhaps a callback or hook has been added since then that
> we could make use of?

I'm not managing to wrap my head around how you could use
MemoryContextCreate directly, unless you are implementing your own memory
context type, in which case the API changes aren't that difficult to make
I should think.

However, if the need is to free some external resources when a memory
context is destroyed, seems like what you ought to be using is a memory
context reset callback.  Look at MemoryContextRegisterResetCallback and
its callers (there are just a couple at the moment, though I'm fooling
with a patch that will add more).

            regards, tom lane


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: MemoryContextCreate change in PG 11 how should contexts becreated
Следующее
От: Paul Ramsey
Дата:
Сообщение: Re: MemoryContextCreate change in PG 11 how should contexts be created