Each process have its own stack and heap, while threads share common heap.
According to wikipedia, when the program (executable or library) is loaded into memory, static variables are stored in the data segment of the program's address space (if initialized), or the BSS segment (if uninitialized), and are stored in corresponding sections of object files prior to loading.
- Elements of a process, the memory map of a process
- Memory Allocation/Deallocation Bottleneck?
- Do different programs gets their memory from a common heap or from a separate heap?
global variables is deallocated before main()
exit