Memory Management in Operating System

Last Updated : 15 Sep, 2026

Memory management is the process of controlling and organizing a computer’s memory by allocating portions, called blocks, to different executing programmes to improve the overall system performance.

  • The most important function of an operating system is to manage primary memory.
  • Supports multiple processes simultaneously in memory.
  • Protects processes from unauthorized access.
  • Enables swapping and virtual memory efficiently.
frame_3761
Memory Management

Memory Management Basics

Techniques in Memory Allocation

Used by an operating system to efficiently allocate, utilize, and manage memory resources for processes. Various techniques help the operating system manage memory effectively. They can be broadly categorized into:

ggg

Contiguous Memory Allocation

Contiguous Memory Allocation is a memory management technique in which an entire process is loaded into a single continuous block of main memory.

Single Contiguous Memory Allocation: It is a memory management technique in which the operating system and one user process are stored in a single continuous block of main memory.

  • Memory is divided into two parts: one for the operating system and one for the user process.
  • A program is loaded into one contiguous (continuous) memory block for execution.
  • Only one user process can reside in memory at a time.

Partitioned Memory Allocation: Main memory is divided into multiple contiguous partitions, and each partition can hold one process. This technique supports multiprogramming. Partitioned memory allocation is further classified into:

  • Fixed Partition Allocation: Fixed Partition Allocation is a memory management technique in which the main memory is divided into a fixed number of partitions of predefined sizes. Each partition can hold only one process at a time. This method is simple to implement but may lead to internal fragmentation when a process does not fully utilize its allocated partition.
  • Variable Partition Allocation: is a memory management technique in which memory partitions are created dynamically according to the size of the process. It reduces internal fragmentation but may lead to external fragmentation over time.

Non-Contiguous Memory Allocation

Non-Contiguous Memory Allocation is a memory management technique in which a process is divided into smaller parts and stored in different locations in main memory. Unlike contiguous allocation, the entire process does not need to occupy a single continuous block of memory, improving memory utilization and reducing fragmentation.

Techniques Used in Non-Contiguous Memory Allocation

  1. Paging: Divides a process into fixed-size pages and memory into frames of the same size
  2. Segmentation: Divides a process into logical segments of variable size such as code, data, and stack
  3. Segmentation with Paging: Combines logical segmentation with paging to reduce fragmentation

Swapping

Swapping is a memory management technique in which processes are temporarily moved between main memory and secondary storage to free memory for other processes.

Memory Management Mechanisms

Virtual Memory

Virtual Memory allows programs larger than physical RAM to run by using disk space as an extension of main memory.

Page Replacement Algorithms(PRA)

PRA decide which page to remove from memory when it is full.

Demand Paging

  • Demand Paging loads only the pages a process actually needs into memory.
  • Reduces unnecessary memory usage and I/O.

Memory Management Problems

Fragmentation

Fragmentation occurs when processes are loaded into and removed from memory, resulting in unused memory spaces that cannot be efficiently utilized.

  • Internal Fragmentation: Occurs when a process is allocated more memory than it actually needs, leading to wasted space inside the allocated memory block.
  • External Fragmentation: Occurs when free memory is divided into small, scattered blocks, making it impossible to allocate a large contiguous block even though enough total free memory exists.

Thrashing

Placement Algorithms

When allocating memory, the OS uses placement algorithms to decide which free block should be assigned to a process:

  • First Fit: Allocates the first available partition large enough to hold the process.
  • Best Fit: Allocates the smallest available partition that fits the process, reducing wasted space.
  • Worst Fit: Allocates the largest available partition, leaving the largest remaining space.
  • Next Fit: Similar to First Fit but starts searching for free memory from the point of the last allocation.

Advanced Memory Concepts

Quiz: Memory Management

Comment