Different Memory segments in C - C++

There are 5 different memory segments in C/C++. They are 

  1. Text Segment
  2. Initialized Data Segment
  3. Uninitialized data segment
  4. Stack
  5. Heap
1.Text Segment is also known as a code memory, where the function description details will be stored

2.Initialized data segment, It is a virtual address space. Initialized static and global variables are stored in this memory.

3.Uninitialized data segment, It is also known as Block Started by Symbol (BSS). Global and static variables which is uninitialized are stored here and that is initialized to kernel zero (0).

4.Stack, In this memory only the local variables are stored, the stack memory area is adjoined heap area, which grew opposite direction. When both of them met then the memory will be free-ed.

5.Heap memory, is known as a dynamic memory. Dynamic memory allocation (malloc, calloc, realloc) during program execution will be in this memory. It begins at the end of BSS.

No comments:

Post a comment