pgstat cleanup: use palloc and AllocateFile

Started by Neil Conwayalmost 22 years ago3 messagespatches
Jump to latest
#1Neil 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

Attachments:

pgstat_malloc_cleanup-3.patchtext/x-patch; charset=ISO-8859-1; name=pgstat_malloc_cleanup-3.patchDownload+49-108
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#1)
Re: pgstat cleanup: use palloc and AllocateFile

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

#3Neil Conway
neilc@samurai.com
In reply to: Tom Lane (#2)
Re: pgstat cleanup: use palloc and AllocateFile

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