Calculate System V or POSIX shared memory segment size requirements for applications.
System V shared memory (used heavily by databases like PostgreSQL for shared_buffers) is bounded by two kernel limits: kernel.shmmax (the largest single segment allowed, in bytes) and kernel.shmall (the total shared memory system-wide, in pages). Applications that request a segment larger than shmmax, or a total exceeding shmall, fail to allocate shared memory at startup — a common cause of database startup failures after increasing configured buffer sizes without also raising these kernel limits.
shmall in pages
shmall_pages = ceil(total_shm_bytes / page_size)
The most common cause is the requested segment exceeding kernel.shmmax, or the cumulative shared memory exceeding kernel.shmall — both must be raised via sysctl (and typically /etc/sysctl.conf for persistence) before increasing an application's shared memory configuration beyond the current limits.
System V shm (shmget/shmat) is the older API governed by kernel.shmmax/shmall/shmmni; POSIX shared memory (shm_open, typically backed by tmpfs under /dev/shm) is governed instead by the size of the /dev/shm mount. Modern applications increasingly prefer POSIX shm, but many established databases still use System V shm.
`ipcs -m` lists active shared memory segments with their sizes and attaching processes, and `ipcs -lm` shows the current kernel limits (shmmax, shmall, shmmni) for comparison against what your applications need.