Memory Allocation
__________________________________________
Definition :-
It is an action of assigning the physical or the virtual memory address space to
a process.
There are two types of memory allocation.
1. Static Memory Allocation
2. Dynamic Memory Allocation
______________________________________________
1. Static Memory Allocation
Definition :-
It is performed when the compiler compiles the program and generates
object files.
In static memory allocation, the size of the data required by the process must be known before the execution of the process initiates.
______________________________________________
Advantages :-
1. Static memory allocation provides an efficient way of assigning the memory to a process.
2. Static memory allocation provides faster execution, as at the time of execution it doesn’t have to waste time in allocation memory to the program.
______________________________________________
Disadvantages :-
Static memory allocation leads to memory wastage. As it estimates the size of memory required by the program. So, if the estimated size is larger, it will lead to memory wastage else if the
estimated size is smaller, then the program will execute inappropriately.
______________________________________________
2. Dynamic Memory Allocation
Definition :-
Dynamic memory allocation is performed while the program is in execution
The program execution creating more overheads,
leading in slow execution of the program.
Advantages :-
1. Dynamic memory allocation provides a flexible way of assigning the memory to a process.
2. Dynamic memory allocation reduces the memory wastage as it assigns memory to a process
during the execution of that program. So, it is aware of the exact memory size required by the
program.
3. If the program is large then the dynamic memory allocation is performed on the different parts of
the program. Memory is assigned to the part of a program that is currently in use. This also
reduces memory wastage and indeed improves system performance.
______________________________________________
Disadvantages :-
1. Dynamic memory allocation method has an overhead of assigning the memory to a process
during the time of its execution.
2. Sometimes the memory allocation actions are repeated several times during the execution of the
program which leads to more overheads.
3. The overheads of memory allocation at the time of its execution slowdowns the execution to
some extent.
