Re: Memory management question - Mailing list pgsql-hackers

From Karel Zak
Subject Re: Memory management question
Date
Msg-id 20020903135209.C14392@zf.jcu.cz
Whole thread Raw
In response to Memory management question  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
Responses Re: Memory management question  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
Re: Memory management question  ("Serguei A. Mokhov" <sa_mokho@alcor.concordia.ca>)
List pgsql-hackers
On Tue, Sep 03, 2002 at 12:28:37PM +0100, Nigel J. Andrews wrote:
> 
> 
> 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 some code doesn't call MemoryContextSwitchTo() all is allocated in
current memory context. You can check if CurrentMemoryContext is same
before and after call that is important for you - but this check say
nothing, bacuse some code can switch to other context and after usage
switch back to your context. IMHO is not common way how check it.
(Ok, maybe check all contexts size before/after call...)
Suggestion: add to memory managment counter that handle number            of MemoryContextSwitchTo() calls. IMHO it can
becompile            only if MEMORY_CONTEXT_CHECKING is define.
 
But I think there is not to much places which switching between
contexts and all are good commented (I hope, I wish :-)
   Karel

-- Karel Zak  <zakkr@zf.jcu.cz>http://home.zf.jcu.cz/~zakkr/C, PostgreSQL, PHP, WWW, http://docs.linux.cz,
http://mape.jcu.cz


pgsql-hackers by date:

Previous
From: Gavin Sherry
Date:
Subject: Re: Memory management question
Next
From: Rod Taylor
Date:
Subject: Re: possible vacuum improvement?