Re: Sort memory not being released - Mailing list pgsql-general

From Tom Lane
Subject Re: Sort memory not being released
Date
Msg-id 13121.1055864331@sss.pgh.pa.us
Whole thread Raw
In response to Re: Sort memory not being released  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Tue, Jun 17, 2003 at 10:45:39AM -0400, Tom Lane wrote:
>> But essentially all our allocation traffic goes through palloc, which
>> bunches small allocations together.  In typical scenarios malloc will
>> only see requests of 8K or more, so we should be in good shape on this
>> front.

> Ah, bad news. The threshold appears to be closer to 64-128KB, so for small
> allocations normal brk() calls will be made until the third or fourth
> expansion.

That's probably good, actually.  I'd imagine that mmap'ing for every 8K
would be a bad idea ... until a context gets up to a few hundred K you
shouldn't get too worried about whether you can eventually give it back
to the OS.

> Obviously memory fragmentation is
> your enemy here.

True.  I think the memory-context structure helps on that, but it cannot
solve it completely.  (AFAIK, no one has yet done any studies to see
what sorts of memory fragmentation issues may exist in a backend that's
been running for a long while.  It'd be an interesting little project
if anyone wants to take it up.)

            regards, tom lane

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: adddepend and partial indexes
Next
From: Tom Lane
Date:
Subject: Re: order of nested loop