Shared memory: shmget fails: No space left on device -- how to increase limits?
Solution 1:
Use ipcs -l
to check the limits actually in force, and ipcs -a
and ipcs -m
to see what is in use, so you can compare the output. Look at the nattch
column: are there segments with no processes attached that were not removed when processes exited (which normally means the program crashed)? ipcrm
can clear them, although if this is a test machine, a reboot is quicker (and will make sure your changes to limits are picked up).
Your kernel parameters seem odd. In particular, shmall
is a count of pages, not bytes, and 4kB is the default page size (run getconf PAGESIZE
to check what you are using). How many terabytes of RAM do you have?
Now, you say you get about 32771 shared memory segments, which is also about 32768 (or 2 to the 15) which suggests a signed 16-bit int is the limiting factor. And what kernel are you running (as this will have its own limits)? The two may be related.
Solution 2:
It turns out shmmni is limited to 32768 in the kernel:
#define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */
in the file ...version.../include/linux/ipc.h
.
So short of recompiling the kernel, that is the hard limit on the number of shared memory segments.