Zone for C + + memory allocation:
1. Stack: Where the program is run, the local variables, and the incoming parameters are stored and recycled at the end of the program .
2. Heap: New assignment, released by delete
3. Free Storage area: malloc distribution
4. Global/Static storage: Where global variables or static variables are stored
5. Constant storage: Where constants are stored, modifications are not allowed
The difference between heap and stack:
1. Management in a different way, the heap is managed by the programmer itself, and the stack is managed by the compiler
2. The size of the space is different, the heap is basically unlimited, and the stack can easily overflow
3. Different growth modes, the heap is the address of the upward increase, and the stack is from the address of the high-to-low change
4. In different ways, the heap is dynamically allocated by the programmer itself, and the stack is freed by the compiler itself.
5. Fragmentation can occur, when a large number of dynamic allocation of memory is fragmented, affecting the execution efficiency of the program, but not on the stack, because the stack allocation
6. The efficiency of allocation is different, the heap allocates memory is inefficient
C + + memory management -1--c++ memory allocation method