Re: Memory management question - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Memory management question
Date
Msg-id 5267.1031060472@sss.pgh.pa.us
Whole thread Raw
In response to Memory management question  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
List pgsql-hackers
"Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:
> It's probably a pretty basic question explained in some document I
> haven't seen but...if I do something like a CreateTupleDescCopy() how
> do I know my memory context owns everything allocated without
> following the code all the way through until it returns to me?

If it doesn't, then it's broken.  A general rule of the system is that
structures being allocated for return to a routine's caller must be
allocated in the caller's CurrentMemoryContext.  The only exceptions are
for cases where the routine in question is taking responsibility for the
long-term management of the object (for example, a syscache) --- in
which case, it isn't your problem.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: findoidjoins
Next
From: Tom Lane
Date:
Subject: Re: possible vacuum improvement?