Introduction
Memory is an essential component of a computer used to store data. Because
the amount of main memory available in a computer system is fairly restricted, its management is crucial to the computer system.
Memory management in OS is the process of regulating and organizing computer memory in order to allocate and deallocate memory
space efficiently for programs and applications that require it. This helps to guarantee that the system runs efficiently and
has enough memory to run apps and tasks.

Role of Memory Management
- Memory manager is used to keep track of the status of memory locations, whether it is free or allocated. It addresses primary memory by providing abstractions so that software perceives a large memory is allocated to it.
- Memory manager permits computers with a small amount of main memory to execute programs larger than the size or amount of available memory. It does this by moving information back and forth between primary memory and secondary memory by using the concept of swapping.
- The memory manager is responsible for protecting the memory allocated to each process from being corrupted by another process. If this is not ensured, then the system may exhibit unpredictable behavior.
- Memory managers should enable sharing of memory space between processes. Thus, two programs can reside at the same memory location although at different times.
Some important terms
- Virtual Memory:A memory management technique that creates an illusion of a large, contiguous block of memory, regardless of the actual physical memory available.
- Logical Address:A logical address (also known as a virtual address) is the address generated by the CPU during the execution of a program.
- Physical Address:A physical address is the actual address in the computer's physical memory (RAM).
- Page Table: A data structure used by the OS to map virtual addresses to physical addresses. It keeps track of the location of each page in physical memory, enabling virtual memory implementation.
- External Fragmentation:Occurs when free memory is divided into small, non-contiguous blocks, making it difficult to allocate large contiguous blocks of memory.
- Internal Fragmentation:Occurs when allocated memory blocks are larger than the requested memory, leading to wasted space within allocated regions.
- Swapping:Swapping is the process of moving a process or part of a process from the main memory (RAM) to a secondary storage (usually a hard disk) and vice versa. This is done to free up memory for other processes that need to run.
Types of Memory Management Techniques

- Single Contiguous Memory Management Schemes:The Single contiguous memory management scheme is the simplest memory management scheme used in the earliest generation of computer systems. In this scheme, the main memory is divided into two contiguous areas or partitions. The operating systems reside permanently in one partition and the user process is loaded into the other partition.
- Multiple Partitioning:The single Contiguous memory management scheme is inefficient as it limits computers to execute only
one program at a time resulting in wastage in memory space and CPU time. The problem of inefficient CPU use can be overcome using
multiprogramming that allows more than one program to run concurrently. To switch between two processes, the operating systems
need to load both processes into the main memory. The operating system needs to divide the available main memory into multiple
parts to load multiple processes into the main memory. Thus multiple processes can reside in the main memory simultaneously.
The multiple partitioning schemes can be of two types:
- Fixed Partitioning:The main memory is divided into several fixed-sized partitions in a fixed partition memory
management scheme or static partitioning. These partitions can be of the same size or different sizes. Each partition can
hold a single process. The number of partitions determines the degree of multiprogramming, i.e., the maximum number of
processes in memory. These partitions are made at the time of system generation and remain fixed after that.
Fig. 4 Fixed Partitioning
Advantages:
- Simple to implement.
- Easy to manage and design.
Disadvantages:
- This scheme suffers from internal fragmentation.
- The number of partitions is specified at the time of system generation.
- Dynamic/Variable Partitioning:The dynamic partitioning was designed to overcome the problems of a fixed partitioning scheme.
In a dynamic partitioning scheme, each process occupies only as much memory as they require when loaded for processing. Requested
processes are allocated memory until the entire physical memory is exhausted or the remaining space is insufficient to hold the
requesting process. In this scheme the partitions used are of variable size, and the number of partitions is not defined at the
system generation time.
Fig. 5 Variable Partitioning
Advantages:
- Simple to implement.
- Easy to manage and design.
Disadvantages:
- This scheme also suffers from internal fragmentation.
- The number of partitions is specified at the time of system segmentation.
- Fixed Partitioning:The main memory is divided into several fixed-sized partitions in a fixed partition memory
management scheme or static partitioning. These partitions can be of the same size or different sizes. Each partition can
hold a single process. The number of partitions determines the degree of multiprogramming, i.e., the maximum number of
processes in memory. These partitions are made at the time of system generation and remain fixed after that.
- First Fit:The first fit algorithm allocates the first block of memory that is large enough to satisfy the request. The system scans memory from the beginning and chooses the first available block that can accommodate the requested size.
- Best Fit:The best fit algorithm allocates the smallest available block of memory that is large enough to satisfy the request. The system scans all available blocks and chooses the one that most closely fits the requested size, minimizing wasted space.
- Worst Fit:The worst fit algorithm allocates the largest available block of memory.The system scans all available blocks and chooses the largest one, leaving larger remaining free blocks.
Contiguous Memory Management Schemes
In a Contiguous memory management scheme, each program occupies a single contiguous block of storage locations, i.e., a set of memory locations with consecutive addresses.
