Re: [GENERAL] memory - Mailing list pgsql-general

From Daniel Kalchev
Subject Re: [GENERAL] memory
Date
Msg-id 199912051406.QAA03457@dcave.digsys.bg
Whole thread Raw
List pgsql-general
Bruce Momjian <pgman@candle.pha.pa.us> wrote:


owner-pgsql-general-digest@hub.org said:
> 1) Can someone explain how postgreSQL uses memory so that I can
> understand
> what I should be doing here.
> BTW, I am running postgres with -B 884. Can someone also explain how
> postgres uses shared mem so that I can have a clue what would be a
> reasonable setting.
>
> 2) Can any BSDI folk give me any tuning tips. I am especially
> interested to
> hear from those who claim "some might tell you that we run equally
> well on
> FreeBSD" or "BSD is the One True Code", of course all help is
> gratefully
> received.

> I have run BSDI for years and never saw this problem.  Not sure on a
> cause, though.

Bruce,

I too run BSD/OS for years and on all BSD/OS versions since 2.1 and Postgres
since 6.0 (earlier postrges releases didn't have much load here) observe the
same problem:

the postgres process never can allocate more than ~74MB of memory! It would
die with (printed on the controlling terminal!?) message:

sbrk: grow failed, return = 12

The postgres log would show

FATAL 1:  Memory exhausted in AllocSetAlloc()

I have actually complained seveal time, and saw recently that the alloc
routines have been rewritten, but with the same result! I now think this may
be something BSD/OS related - I never ever see a postgres process allocate
more than 74 MB memory! :-)

The resource limits when postrges is started are:

coredumpsize    unlimited
cputime         unlimited
datasize        262144 kbytes
filesize        unlimited
maxproc         4116
memorylocked    256164 kbytes
memoryuse       256160 kbytes
openfiles       13196
stacksize       262144 kbytes

This is one of the most mysterious things I ever saw on using BSD/OS and
PostgreSQL.... and of course - shared memory and semaphores! :-)

I have my BSD/OS kernel (3.1) configured with these options

options         "DFLDSIZ=\(64*1024*1024\)"
options         "MAXDSIZ=\(256*1024*1024\)"
options         "CHILD_MAX=256"
options         "OPEN_MAX=256"
options         "KMAPENTRIES=4000" # Prevents kmem malloc errors !
options         "KMEMSIZE=\(32*1024*1024\)"
# shared memory setup for Postgres
options         "SHMMAXPGS=32768"
options         "SHMMNI=400"
options         "SHMSEG=204"
# More semaphores for Postgres
options         "SEMMNS=600"


sometimes, it logs messages such as

IpcMemoryCreate: shmget failed (Cannot allocate memory) key=5432401,
size=2661376, permission=600

Postgres is started with

postmaster -D/usr/local/pgsql/data -B 256 -i -o "-e -S 8192" >>
/usr/local/pgsql/errlog 2>&1 &

Weird...

Daniel


pgsql-general by date:

Previous
From: Herbert Liechti
Date:
Subject: Re: [GENERAL] PostgreSQL 6.5.3 on SuSE 6.1
Next
From: "USSL"
Date:
Subject: PostgreSQL and Java