Memory leak with palloc - Mailing list pgsql-general

From Han Holl
Subject Memory leak with palloc
Date
Msg-id 200211291516.30424.han.holl@prismant.nl
Whole thread Raw
Responses Re: Memory leak with palloc  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hello,

Let's say I want to run
select
  count(column1) as column1,
  count(column2) as column2,
  ...
  count(column228) as column228
from aview;

coulumni are really function calls that return a computed
text that is palloc'd.
Postgres seems to free the palloc'd memory at the end of the
select statement, which means that the above query may of may
not succeed depending on machine size, database size and amount
of memory allocated.
Is there a way (and if there isn't, should there be) to tell
postgres either:
  1. Please release this memory when you're done with this record.
or 2. Here is a pointer to static memory. Please don't free.

Both would solve my problem (and I guess 2 would be the more efficient).

Cheers,

Han Holl

PS The above query failed very quickly indeed on Postgres 7.2.3, (due to
memory exhaustion,) which seems to have a additional memory leak of it's
own. On 7.3RC2 it's running fine but consuming memory at a steady rate
(from 10M to 115M in 35 minutes, with 1.3G virtual memory I', confident
that it will complete).



pgsql-general by date:

Previous
From: David Crawshaw
Date:
Subject: Re: FETCH a cursor inside a SELECT
Next
From: "Shridhar Daithankar"
Date:
Subject: Re: FETCH a cursor inside a SELECT