Tuesday, February 14, 2012

Memory organization in C programming language

Memory is organized in four segments namely text, data, heap and stack segments.

Text segment: This is also called the code segment. all the text will be stored here.

data segment: All the data will be stored here. this segment diveded into BSS and non-BSS portions. In BSS (Block Started by Symbol) all uninitialized static and global variables stored. and initialized and constant variables will be stored in non-BSS portion.

stack segment: All the local variables will be stored here. during the fucntion call stack segment will be used to store the function return address and the local

variables of that function.

Heap segment: this is used for dynamic memory allocation. this memory area can be used by calling malloc, calloc functions.

See the below images for more clarity:

General memory organization

Unix & Windows

No comments:

Popular Posts