EN
My tools

Page Replacement Algorithm Calculator (FIFO, LRU, Optimal)

Simulate FIFO, LRU, Optimal, LFU and Clock page replacement: frames after every reference, hits and page faults, hit ratio, and a Belady's anomaly check.

Page faults
12
LRU, 3 frames
Hits
8
Hit ratio
40%
Fault ratio
60%

No Belady's anomaly in this range: no algorithm got more faults with more frames.

LRU replaces the page whose last use is longest ago.

Page faults by number of frames
  • FIFO
  • LRU
  • Optimal
  • LFU
  • Clock
Page faults by number of frames: FIFO, LRU, Optimal, LFU, Clock051015201234567Frames
LRU with 3 frames
#PageFrame 1Frame 2Frame 3ResultEvicted
177FAULT
2070FAULT
31701FAULT
42201FAULT7
50201hit
63203FAULT1
70203hit
84403FAULT2
92402FAULT3
103432FAULT0
110032FAULT4
123032hit
132032hit
141132FAULT0
152132hit
160102FAULT3
171102hit
187107FAULT2
190107hit
201107hit
Page faults by number of frames
FramesFIFOLRUOptimalLFUClock
12020202020
21517131515
3151291314
4108899
597779
666666
766666
My tools →
Advertisement

When memory is full and a program needs a page that is not loaded, the operating system must choose a page to throw out. The choice decides how many page faults happen. This calculator runs the classic replacement algorithms — FIFO, LRU, Optimal, LFU and Clock (second chance) — on a reference string, shows the frames after every reference with hits and faults, gives the hit ratio, and compares all algorithms for every number of frames, which reveals Belady's anomaly when it occurs.

How to use this tool

  1. Type the reference string: the page numbers in the order they are used.
  2. Set the number of frames.
  3. Choose the algorithm.
  4. Read the frame table, the fault count and the comparison by number of frames.

Formula

hit ratio = hits ÷ references · fault ratio = faults ÷ references · faults include the first loads into empty frames

FIFO evicts the page loaded earliest; LRU the page used least recently; Optimal the page whose next use is farthest away (or that is never used again); LFU the page used least often since it was loaded (ties: loaded earliest); Clock goes round the frames clearing reference bits and evicts the first page whose bit is already clear. Every algorithm counts the initial loads as faults, as textbooks do. The comparison table repeats the run for 1 to 12 frames.

Example

With the textbook string 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 and 3 frames, LRU gives 12 page faults and 8 hits (40% hit ratio), FIFO gives 15, Clock 14 and Optimal 9 — the lower bound. With the string 1 2 3 4 1 2 5 1 2 3 4 5, FIFO makes 9 faults with 3 frames but 10 with 4: Belady's anomaly.

Frequently asked questions

What is Belady's anomaly?

For some reference strings FIFO causes more page faults when it is given more frames. LRU and Optimal are stack algorithms — the pages in k frames are always a subset of those in k + 1 frames — so they never show it.

Why is Optimal not used in real systems?

It needs to know the future order of page references. It serves as a yardstick: no algorithm can have fewer faults on the same string.

Do the first loads count as faults?

Yes. A page that is not in memory causes a fault whether or not a frame is free; these are called compulsory or cold misses.

Sources

Last updated:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). Page Replacement Algorithm Calculator (FIFO, LRU, Optimal). https://kakao.mobile/tools/page-replacement-simulator/

MLA

“Page Replacement Algorithm Calculator (FIFO, LRU, Optimal).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/page-replacement-simulator/.

Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms

Advertisement