Re: Question regarding the internal memory management

From: Holger Krug <hkrug(at)rationalizer(dot)com>
To: Biker Conrad <bikerc(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Question regarding the internal memory management
Date: 2002-01-18 09:10:16
Message-ID: 20020118101016.A4997@dev12.rationalizer.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)rationalizer(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2002-01-18 09:44:57 Re: Books on PostgreSQL
Previous Message Biker Conrad 2002-01-18 08:09:38 Question regarding the internal memory management