Stores automatic variable such as local variable, function parameters and function return address. Data stored here is automatically allocated and released in execution time.
Stores data that is dynamically allocated by programmer using function such as malloc() and calloc() (in C++ we use "new" operator). Operating system might or might not release the memory after the program exit.
p1 = (char*)malloc(10); p2 = new char;
Allocate char array with size of 10 in heap section. Be careful, p1 and p2 themselves are automatic variable stored in stack section.
(1) memory leak
(2) it can cause external fragmentation, especially when we dynamically allocate variables with various size
Stores global variable and static variable. This section can be further separated to Data section and Bss section.
Data section stores initialized global and static variable, while Bss section stores uninitialized global and static variable.
Stores string constant. Memory is released after program exit.
Stores binary codes.