Overlays in Memory Management (original) (raw)

Last Updated : 15 Apr, 2026

Overlays are a memory management technique used to efficiently manage limited memory by loading only necessary parts of a program into memory at a time. This allows larger programs to run smoothly, even when the available memory is smaller than the program's size.

overlays

Overlay

**Note: In fixed partitioning, If a process exceeds the size of assigned fixed-sized partition, it cannot span across multiple partitions. Overlays solve this issue by allowing parts of the program to be loaded and unloaded as needed, making better use of the available memory.

How Overlays Work:

Example of Overlays -> Assembler with Two Passes:

Consider an assembler that works in two passes. In this, only one pass can be performed at a time. The assembler finishes the first pass and once it's completed, it moves on to the second pass. Let's assume the available main memory size is 150 KB and the total code size is 200 KB. Here's how the program is structured:

Problem:

Since the total code size is 200 KB and the available memory is 150 KB, it is not possible to load both passes into memory at the same time. Therefore, we need to use the overlays technique to efficiently manage the memory.

How Overlays Work in This Case:

As here, only one pass is needed at a time. Both passes always require the symbol table and common routine. So, the overlays technique works by loading one pass at a time, along with the shared symbol table and common routine and then swapping out the pass once it is done.

Memory Requirements:

**For Pass 1:

**Total memory required for Pass 1 = 70 KB + 30 KB + 20 KB + 10 KB = 130 KB.

**For Pass 2:

**Total memory required for Pass 2 = 80 KB + 30 KB + 20 KB + 10 KB = 140 KB.

Minimum Partition Size:

Since Pass 1 requires 130 KB and Pass 2 requires 140 KB, the minimum partition size required for this overlay process is 140 KB. This allows us to load either pass into memory along with the shared resources (symbol table, common routine and overlays driver) without exceeding the available memory.

Overlays Driver

The overlays driver is the user's responsibility. The operating system does not provide an automatic mechanism for swapping the different parts of the program in and out of memory. The user must manually manage the overlay process.

**Question: In The below overlay tree for a program, What will be the size of the partition (in physical memory) required to load (and run) this program?

  1. 12 KB
  2. 14 KB
  3. 10 KB
  4. 8 KB

**Explanation: Using the overlay concept we need not actually have the entire program inside the main memory. Only we need to have the part which are required at that instance of time, either we need Root -> A -> D or Root -> A -> E or Root -> B -> F or Root -> C -> G part.

Root + A + D = 2KB + 4KB + 6KB = 12KB
Root + A + E = 2KB + 4KB + 8KB = 14KB
Root + B + F = 2KB + 6KB + 2KB = 10KB
Root + C + G = 2KB + 8KB + 4KB = 14KB

**Answer: (2) 14 KB, So if we have 14 KB size of partition then we can run any of them.