Vaidikalaya

Non-Contiguous Allocation in Operating System


Non-contiguous memory allocation is a memory management technique in which a process’s memory is not allocated in one continuous block. Instead, a process is divided into parts, and each part can be placed in different locations of memory, possibly scattered across physical RAM.

  • Process is split into smaller units (pages/segments).
  • These parts are placed in available free blocks (frames) of memory.
  • OS maintains mapping through page tables or segment tables

Why Use Non-Contiguous Memory Allocation?

Contiguous allocation is simple but has serious limitations (fragmentation, resizing issues, poor utilization). Non-contiguous allocation was introduced to overcome these problems and improve flexibility.

  • Eliminates External Fragmentation: It allows a process to be split across different free frames. So It avoid external fragmentation.
  • Supports Large Processes: With non-contiguous allocation, a process can be broken into smaller parts (pages/segments) and distributed → supports very large programs.
  • Better Multiprogramming: Multiple processes can easily share memory since each process is split into smaller parts. This increases the degree of multiprogramming (number of processes in memory at a time).
  • Virtual Memory Support: Non-contiguous allocation (paging + segmentation) forms the basis of virtual memory. Virtual memory allows programs to run even if they don’t fit entirely in physical RAM by using disk + RAM together.
  • Logical Program Structure: Programs are naturally divided into modules (code, stack, heap, data). With segmentation, each module can be placed separately in memory.
  • Efficient Use of Memory: Processes can be stored in non-adjacent free spaces, which improves memory utilization.

Techniques of Non-Contiguous Memory Allocation

In non-contiguous memory allocation, a process does not need to occupy a single continuous block of memory. Instead, it can be divided into smaller units and placed in different locations across physical memory.

There are two fundamental approaches to implement non-contiguous memory allocation:

Paging:

It breaks processes into equal-sized pages and maps them to memory frames, mainly to eliminate external fragmentation. Paging avoids external fragmentation but may suffer from internal fragmentation.

Segmentation:

It divides processes into variable-sized logical segments (like code, data, stack), supporting protection, sharing, and logical organization.