Skip site navigation (1) Skip section navigation (2)

mbutils.c memory cxt cleanup

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: mbutils.c memory cxt cleanup
Date: 2006-01-11 19:46:02
Message-ID: 1137008762.9143.88.camel@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-patches
Attached is a patch that changes mbutils.c to perform some long-term
allocations in its own memory context, rather than using
TopMemoryContext. This makes it easier to reclaim the memory that is
allocated: fmgr_info() might perform allocations in the current memory
context, so resetting that context is the most fool-proof way to
cleanup.

I had thought that resetting the FmgrInfo's fn_mcxt was the *only* way
to safely cleanup, but AFAICT there's no actual leak as long as the code
is careful to pfree() both the FmgrInfo and the FmgrInfo's fn_extra
field. However, I think that's a fragile assumption to make, and IMHO
using a separate context is cleaner anyway.

Barring any objections I'll apply this (only to HEAD) later today or
tomorrow.

-Neil


Attachment: mbutils_mcxt_cleanup-1.patch
Description: text/x-patch (4.4 KB)

Responses

pgsql-patches by date

Next:From: Tom LaneDate: 2006-01-11 20:17:16
Subject: Re: TODO-item: Add sleep() function, remove from regress.c
Previous:From: Andrew DunstanDate: 2006-01-11 04:14:46
Subject: Re: TODO-item: Add sleep() function, remove from regress.c

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group