20- C Memory Organization

This chapter will describe the memory organization in C. We will also discuss memory management functions. We are already introduced with this concept in the preceding chapters and this section is going to elaborate the knowledge we already gained. Let us start discussing the section.

21.1 C MEMORY MAP

When we compile any C program, compiler creates following logical sections:

  • Program Memory
  • Global/static variables
  • Heap memory
  • Stack (local variables)

Let us consider a conceptual visualization of memory where we consider the memory size as 1 MB (1024x1024=1048576 bytes). Addresses are marked in increasing order sequentially (0-1048575) which corresponds to addresses reserved for program, global and static variables, data and heap memory but addresses reserved for local variables will be decreasing order of memory addresses. Let us consider the following diagram of memory map: 

Like us on Facebook