Skip to main content

Posts

Showing posts from 2012

Memory Allocation/Segmentation in C/C++

Memory Allocation/Segmentation in C/C++

=========
| stack |
| vv |
| |
| |
| ^^ |
| heap |
=========
| bss |
=========
| data |
=========
| text |
=========
address 0


SegmentDescriptionCodetext segmentOften referred to as the text segment, this is the area in which the executable instructions reside.  For example, Linux/Unix arranges things so that multiple running instances of the same program share their code if possible.  Only one copy of the instructions for the same program resides in memory at any time.  The portion of the executable file containing the text segment is the text section.Initialized data – data segmentStatically allocated and global data that are initialized with nonzero values live in the data segment.  Each process running the same program has its own data segment.  The portion of the executable file containing the data segment is the data section.Uninitialized data – bss segmentBSS stands for ‘Block Started by Symbol’.…