Re: Question regarding the internal memory management - Mailing list pgsql-general

From Holger Krug
Subject Re: Question regarding the internal memory management
Date
Msg-id 20020118101016.A4997@dev12.rationalizer.com
Whole thread Raw
In response to Question regarding the internal memory management  ("Biker Conrad" <bikerc@yahoo.com>)
List pgsql-general
On Fri, Jan 18, 2002 at 12:09:38AM -0800, Biker Conrad wrote:
> I am new to postgreSQL and I was wondering where I can find more information
> regarding the memory allocation and deallocation process in postgreSQL.
> Basically, I read the parser yacc grammar (src/backend/parser/gram.y) and I
> couldn't figure out when does the program deallocate the nodes created
> during the parsing process (using the makeNode macro) in case there are
> parsing errors. If didn't have time to dig more and I thought maybe someone
> can answer my question or can direct me to some documentation about this
> topic.

`makeNode' calls `newNode' and newNode call `palloc'.
`palloc' performs the memory allocation in `CurrentMemoryContext',
which is `QueryContext' for parsing.

Concerning `QueryContext' I'll cite from the code (postgres.c):

     * QueryContext is reset once per iteration of the main loop, ie, upon
     * completion of processing of each supplied query string. It can
     * therefore be used for any data that should live just as long as the
     * query string --- parse trees, for example.

src/backend/utils/mmgr/README informs you about how memory management is done
in PostgreSQL.

--
Holger Krug
hkrug@rationalizer.com

pgsql-general by date:

Previous
From: "Biker Conrad"
Date:
Subject: Question regarding the internal memory management
Next
From: Justin Clift
Date:
Subject: Re: Books on PostgreSQL