pgstat cleanup: use palloc and AllocateFile
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
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
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