The figure is a schematic diagram of the virtual address space of the process.
Stack segment:
1 provide storage for local variables inside a function.
2. When a function call, stored "Process Activity Log."
3. as a temporary storage area. When computing a long arithmetic expression, you can be part of the calculation result onto the stack.
Data segment (static memory):
BSS segment includes a data segment, the segment storage BSS uninitialized global variables, static variables. Data storage segment through global and static variable initialization.
Snippet:
Also called text segment. Store instructions executable files.
stack:
Like the stack segment can grow automatically as needed, the data segment is also a target for the completion of this work, this is the heap (heap). Heap area for storing dynamic allocation, i.e. a live memory malloc function. calloc and malloc and realloc similar. Before former returns a pointer to the allocated memory contents are cleared to zero. The latter change the size of a memory block pointer points, can expand and shrink, he often copied elsewhere memory then returns the new address.
1, the stack area (stack): allocated by the compiler automatically released, the stored function parameters, local variables, and the like. Operate similarly to a stack data structure.
2, the heap area (heap): releasing assigned by the programmer, if the programmer does not release at the end of the program may be recovered by the OS. Note that it is a stack data structure totally different, it touches similar distribution list.
3, the overall area (static region): global variables and static variables are stored in one and the other an initialized global and static variables in an area, uninitialized global variables and static variables uninitialized adjacent region. After the end of the program released by the system.
4, literals area: constant string is placed here. After the end of the program released by the system.
5, the program code area: storing binary code function body.
2. 弹栈(出栈):返回栈顶指向的对象或数据,并从栈中删除该对象或数据,更新栈顶。