Re: dynamically allocating chunks from shared memory - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: dynamically allocating chunks from shared memory
Date
Msg-id 201008091631.o79GVj815207@momjian.us
Whole thread Raw
In response to Re: dynamically allocating chunks from shared memory  (Bruce Momjian <bruce@momjian.us>)
Responses Re: dynamically allocating chunks from shared memory
Re: dynamically allocating chunks from shared memory
List pgsql-hackers
Bruce Momjian wrote:
> > With our process-based design, the default is private memory (i.e. not 
> > shared). If you need shared memory, you must specify a certain amount in 
> > advance. That chunk of shared memory then is reserved and can't ever be 
> > used by another subsystem. Even if you barely ever need that much shared 
> > memory for the subsystem in question.
> 
> Once multiple threads are using the same local memory, you have the same
> issues of being unable to resize it because repalloc can change the
> pointer location.

Let me be more concrete.  Suppose you are using threads, and you want to
increase your shared memory from 20MB to 30MB.  How do you do that?  If
you want it contiguous, you have to use realloc, which might move the
pointer.  If you allocate another 10MB chunk, you then have shared
memory fragments, which is the same as adding another shared memory
segment.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


pgsql-hackers by date:

Previous
From: Daniel Oliveira
Date:
Subject: Universal B-tree
Next
From: Tom Lane
Date:
Subject: Re: ERROR: argument to pg_get_expr() must come from system catalogs