Memory Layout
Came across this article http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory/, and the pictorial illustration is very clear. Here’s a short program to confirm the layout:
1 | #include <stdio.h> |
The output on my box is:
1 | 0x7ffdb10979a8 |
Some observation (mentioned in the article):
- stack starts from high address
- mmap region is placed below stack, and grows downwards
- mmap anonymous memory is page (4k) align
- heap starts from low address, and grows upwards