Course Content
Operating Systems (OS)
Belady’s Anomaly

Belady’s Anomaly is a counterintuitive behavior in memory management where increasing the number of page frames results in more page faults rather than fewer. This anomaly occurs under certain page replacement algorithms, notably FIFO (First-In, First-Out), and challenges the intuitive assumption that more memory always leads to better performance.


What Is Belady’s Anomaly?

In virtual memory systems, we generally assume that giving a process more page frames will reduce the number of page faults. However, Belady’s Anomaly shows that under specific conditions, the opposite can happen: more memory causes more page faults.

This phenomenon was discovered by Laszlo Belady and is observed primarily with FIFO page replacement algorithms.


How It Happens

Belady’s Anomaly arises due to how FIFO replaces pages. It simply removes the oldest page, without considering how recently or frequently it has been used.

 

Let’s say a process accesses a sequence of pages. Under FIFO:

 

  • With fewer frames, certain older pages are replaced earlier.
  • With more frames, those same pages stay longer, leading to more faults later.

In some cases, this causes more page faults despite having more memory.


Characteristics of the Anomaly
Feature Description
Algorithm affected Most commonly FIFO (First-In, First-Out).
Behavior type Non-monotonic: faults don’t always decrease with more frames.
Occurs when Specific page reference patterns are combined with poor replacement logic.
Doesn’t occur in LRU (Least Recently Used), Optimal Replacement (OPT).

Real-World Analogy

 

Imagine you’re managing a small shelf (memory) for your study books. You decide to always remove the book you placed first (FIFO) to make space for new ones.

 

  • When you had 3 spots, you rotated books quickly and often ended up keeping the most important ones close.

 

  • Later, when you expanded to 4 spots, you held onto older books longer, but this delayed getting back the one you actually needed. You had to keep removing and adding, disrupting your study more often.

 

This is Belady’s Anomaly in practice—more space but worse outcomes.


Why It Matters

  • Belady’s Anomaly highlights the limitations of naive algorithms like FIFO.

 

  • It emphasizes the need for intelligent page replacement strategies based on actual usage patterns.

 

  • It’s a reminder that increased resources alone don’t guarantee better performance without smarter management.

How to Avoid It

Use algorithms that track access patterns, such as:

 

  • LRU (Least Recently Used) – avoids the anomaly because it removes the least recently accessed page.

 

  • Optimal Replacement – theoretical model that always produces the fewest faults.

 

  • Clock or Second-Chance – practical approximations of LRU.
0% Complete
WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.