Thread: pgstat cleanup: use palloc and AllocateFile

pgstat cleanup: use palloc and AllocateFile

From
Neil Conway
Date:
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


Attachment

Re: pgstat cleanup: use palloc and AllocateFile

From
Tom Lane
Date:
Neil Conway <neilc@samurai.com> 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

From
Neil Conway
Date:
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