pgstat cleanup: use palloc and AllocateFile

Поиск
Список
Период
Сортировка
Искать

pgstat cleanup: use palloc and AllocateFile

От:
Neil Conway <neilc@samurai.com>
Дата:
Вложения:
This patch changes pgstat.c to use palloc(), AllocateFile() and
FreeFile() rather than malloc(), fopen() and fclose(), respectively.

I changed more_tabstat_space() (which is invoked at various times
indirectly throughout the backend) to allocate memory in its own private
memory context, rather than use malloc() -- we can't just use
CurrentMemoryContext because that may not be sufficiently long-lived.

Barring any objections I intend to apply this to HEAD tomorrow.

-Neil

Re: pgstat cleanup: use palloc and AllocateFile

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Neil Conway  writes:
> I changed more_tabstat_space() (which is invoked at various times
> indirectly throughout the backend) to allocate memory in its own private
> memory context, rather than use malloc() -- we can't just use
> CurrentMemoryContext because that may not be sufficiently long-lived.

I'd suggest just allocating the tabstat space in TopMemoryContext.  The
extra sub-context is useless overhead, since you don't actually use it
for management purposes.

			regards, tom lane

Re: pgstat cleanup: use palloc and AllocateFile

От:
Neil Conway <neilc@samurai.com>
Дата:
On Thu, 2004-10-28 at 02:20, Tom Lane wrote:
> I'd suggest just allocating the tabstat space in TopMemoryContext.  The
> extra sub-context is useless overhead, since you don't actually use it
> for management purposes.

I don't know why I didn't think of that :)

Patch applied with your suggested change.

-Neil


FAQ