Programming in C: Unit III (b): Pointers

Memory Usage

Programming in C

Before jumping into dynamic memory allocation, let us first understand how memory is used. Conceptually, memory is divided into two-program memory and data memory

MEMORY USAGE

Before jumping into dynamic memory allocation, let us first understand how memory is used. Conceptually, memory is divided into two-program memory and data memory (Figure 7.10).

The program memory consists of memory used for the main () and other called functions in the program, whereas data memory consists of memory needed for permanent definitions such as global data, local data, constants, and dynamic memory data. The way in which c handles the memory requirements is a function of the operating system and the compiler.

When a program is being executed, its main () and all other functions are always kept in the memory. However, the local variables of the function are available in the memory only when they are active. When we studied recursive functions, we have seen that the system stack is used to store a single copy of the function and multiple copies of the local variables.

Apart from the stack, we also have a memory allocation known as heap. Heap memory is unused memory allocated to the program and available to be assigned during its execution. When we dynamically allocate memory for variables, heap acts as a memory pool from which memory is allocated to those variables.

However, this is just a conceptual view of memory and implementation of the memory is entirely in the hands of system designers.

Programming in C: Unit III (b): Pointers : Tag: : Programming in C - Memory Usage


Programming in C: Unit III (b): Pointers



Under Subject


Programming in C

CS3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation



Related Subjects


Professional English II

HS3251 2nd Semester 2021 Regulation | 2nd Semester Common to all Dept 2021 Regulation


Statistics and Numerical Methods

MA3251 2nd Semester 2021 Regulation M2 Engineering Mathematics 2 | 2nd Semester Common to all Dept 2021 Regulation


Engineering Graphics

GE3251 eg 2nd semester | 2021 Regulation | 2nd Semester Common to all Dept 2021 Regulation


Physics for Electrical Engineering

PH3202 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Basic Civil and Mechanical Engineering

BE3255 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Electric Circuit Analysis

EE3251 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Physics for Electronics Engineering

PH3254 - Physics II - 2nd Semester - ECE Department - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Electrical and Instrumentation Engineering

BE3254 - 2nd Semester - ECE Dept - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Circuit Analysis

EC3251 - 2nd Semester - ECE Dept - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Materials Science

PH3251 2nd semester Mechanical Dept | 2021 Regulation | 2nd Semester Mechanical Dept 2021 Regulation


Basic Electrical and Electronics Engineering

BE3251 2nd semester Mechanical Dept | 2021 Regulation | 2nd Semester Mechanical Dept 2021 Regulation


Physics for Civil Engineering

PH3201 2021 Regulation | 2nd Semester Civil Dept 2021 Regulation


Basic Electrical, Electronics and Instrumentation Engineering

BE3252 2021 Regulation | 2nd Semester Civil Dept 2021 Regulation


Physics for Information Science

PH3256 2nd Semester CSE Dept | 2021 Regulation | 2nd Semester CSE Dept 2021 Regulation


Basic Electrical and Electronics Engineering

BE3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation


Programming in C

CS3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation