HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 32 (of 101)
Chapter 11 Software Development
October 29, 2013
Shared Memory
As the name implies, data in the shared quadrants is shared between processes. There are two
types of shared memory on HP-UX, System V shared memory (shmget(2), shmat(2) etc.) and
shared mappings (mmap(2) with the MAP_SHARED attribute). Shared library text is made available
to processes using shared mappings.
Limitations
There are various limits for memory allocation:
ulimit -d
kernel parameters
quadrant size (process address space)
virtual memory (swap space)
The kernel parameters that delimit the amount of private memory a process can allocate, are:
maxdsiz[_64bit]: Maximum process heap size (not total private data)
maxssiz[_64bit]: Maximum process stacksize
maxdsiz[_64bit] represents the maximum amount of private data a process can allocate on the
heap using malloc(2). It has no effect on the amount of data that can be allocated by mmap(2).
There is no limit for mmap(2) other than the private address space that is available to the process,
and the total virtual memory available to the system.
Normally, programs don't need much space on the stack, so the default setting of 8 MB for
maxssiz is sufficient in most cases. When increasing maxssiz, be aware that this amount is
reserved for the stack and will reduce the space available for heap and privately mapped regions.
If the maximum amount of allocatable memory in a program is much less than 1 GB, check your
maxssiz setting.
The size of the process heap will also be limited by the posix shell built-in command ulimit -d.
While maxdsiz is a system wide limit, ulimit -d only applies to the current process and all its
descendants. The initial ulimit for the process heap is equal to maxdsiz[_64bit]. The shell will
always display the ulimit for 32-bit processes, since it is a 32-bit process itself. But if the ulimit
is set in a shell, the setting applies to both 32- and 64-bit processes started by this shell.
The amount of allocatable System V shared memory is not limited on a per process base,
because it cannot be associated to a single process. Any process can create and attach to shared
regions. There are however a few related kernel parameters:
shmmax: Maximum segment size
shmseg: Maximum number of segments per process
shmmni: Maximum system wide number of segments