What is the limit on number of shared memory segments

What is the limit on number of shared memory segments I can attach?


Each process has 16 segments. One is used for private code, one for
stack, one for heap; those, if memory serves, are segments 0, 1, and
2. (If you look in sys/shm.h, you'll see that SHMLOSEG is 3 -- the
lowest segment, in number and in the process' virtual address space,
available to shmat.)

SHMHISEG, the highest segment you can attach to (also defined in
sys/shm.h), is 12. Segments 3 through 12 are available to shmat,
giving the 10 segments your program used successfully. (NSHMSEGS in
sys/shm.h will give you this value, though it's of limited use, since
most platforms that I've seen don't define it.)

Segment 13 is used by shared code your program has attached to;
I think one of the others might be for kernel-mode data.

See also mmap.



Home FAQ