C - Memory Model of C Program

Definition

The memory model of a C program describes how a program is organized in memory during execution.

Components

  • Text Segment – Stores compiled program instructions

  • Data Segment – Stores initialized global and static variables

  • BSS Segment – Stores uninitialized global and static variables

  • Heap – Dynamic memory allocation during runtime

  • Stack – Function calls, local variables, return addresses

Importance

Understanding the memory model helps in:

 

  • Efficient memory usage

  • Avoiding memory leaks

  • Debugging segmentation fault