Stack area: Mainly used for storing local variables , passing parameters , storing the return address of the function. . ESP always points to the top of the stack, the more data in the stack , the smaller the value of the ESP.
Heap area: Used to store dynamically allocated objects , when you use malloc and New to allocate, the resulting space is in the heap. Dynamically allocated areas of memory are provided with allocation information , so you can free and delete them.
Data area: Global, static, and constant are allocated in the data area, and the data area includes BSS (uninitialized data area) and initialization data area.
Attention:
1) heap to high memory address growth;
2) stack to low memory address growth;
3) heap and stack are opposite, there is a critical point between heap and stack, called stkbrk.
1 , a process in-memory mapping
Suppose you now have a program that has the following sequence of function calls:
Main (...)->; func_1 (...)->; func_2 (...)->; func_3 (...), that is: main function main call function func_1; function func_ 1 call function func_2; function func_2 call function func_3.
When a program is called into memory by the operating system , the mapping of its corresponding process in memory is as follows:
iOS Development variables and memory