I try to figure out the range of the shared memory segment i.e. the memory mapping segment in the memory layout of a process, from two sources below.
From https://manybutfinite.com/post/anatomy-of-a-program-in-memory/, I found a diagram of memory layout of a process
Do memory mapping segment and heap grow until they meet each other?
Or is there a limit for each of the two segments to grow up to, similar to RLIMIT_STACK for the stack segement?
From The Linux Programming Interface
To allow space for heap and stack growth, shared memory segments are attached starting at the virtual address 0x40000000 . Mapped mappings (Chapter 49) and shared libraries (Chapters 41 and 42) are also placed in this area. (There is some variation in the default location at which shared memory mappings and memory segments are placed, depending on the kernel versions and the setting of the process’s RLIMIT_STACK resource limit.) The address 0x40000000 is defined as the kernel constant TASK_UNMAPPED_BASE.
Does the shared memory segment start at TASK_UNMAPPED_BASE and grow upward?
Note that the previous diagram shows the shared memory segment grow downward, so does it grow upward or downward?
Thanks.
RLIMIT_AS
in the two diagrams? (2) if shared memory segment grows downward, what doesTASK_UNMAPPED_BASE
mean? (3) are shared memory segment and memory mapping segment the same concept? – Tim Sep 02 '18 at 21:10RLIMIT_AS
doesn’t appear in the diagrams; it’s a limit which is checked before each allocation. (2) See my update.TASK_UNMAPPED_BASE
is only relevant for bottom-up allocations. (3) The two segments aren’t the same concept but the end up in the same virtual memory area. – Stephen Kitt Sep 04 '18 at 08:55