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.
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.
- FIFO
- LRU
- Optimal
- LFU
- Clock
| # | Page | Frame 1 | Frame 2 | Frame 3 | Result | Evicted |
|---|---|---|---|---|---|---|
| 1 | 7 | 7 | FAULT | |||
| 2 | 0 | 7 | 0 | FAULT | ||
| 3 | 1 | 7 | 0 | 1 | FAULT | |
| 4 | 2 | 2 | 0 | 1 | FAULT | 7 |
| 5 | 0 | 2 | 0 | 1 | hit | |
| 6 | 3 | 2 | 0 | 3 | FAULT | 1 |
| 7 | 0 | 2 | 0 | 3 | hit | |
| 8 | 4 | 4 | 0 | 3 | FAULT | 2 |
| 9 | 2 | 4 | 0 | 2 | FAULT | 3 |
| 10 | 3 | 4 | 3 | 2 | FAULT | 0 |
| 11 | 0 | 0 | 3 | 2 | FAULT | 4 |
| 12 | 3 | 0 | 3 | 2 | hit | |
| 13 | 2 | 0 | 3 | 2 | hit | |
| 14 | 1 | 1 | 3 | 2 | FAULT | 0 |
| 15 | 2 | 1 | 3 | 2 | hit | |
| 16 | 0 | 1 | 0 | 2 | FAULT | 3 |
| 17 | 1 | 1 | 0 | 2 | hit | |
| 18 | 7 | 1 | 0 | 7 | FAULT | 2 |
| 19 | 0 | 1 | 0 | 7 | hit | |
| 20 | 1 | 1 | 0 | 7 | hit |
| Frames | FIFO | LRU | Optimal | LFU | Clock |
|---|---|---|---|---|---|
| 1 | 20 | 20 | 20 | 20 | 20 |
| 2 | 15 | 17 | 13 | 15 | 15 |
| 3 | 15 | 12 | 9 | 13 | 14 |
| 4 | 10 | 8 | 8 | 9 | 9 |
| 5 | 9 | 7 | 7 | 7 | 9 |
| 6 | 6 | 6 | 6 | 6 | 6 |
| 7 | 6 | 6 | 6 | 6 | 6 |
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
- Type the reference string: the page numbers in the order they are used.
- Set the number of frames.
- Choose the algorithm.
- 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:
Page address with these inputs: https://kakao.mobile/tools/page-replacement-simulator/
Cite or embed this tool
kakaoCalc. (2026, November 8). Page Replacement Algorithm Calculator (FIFO, LRU, Optimal). https://kakao.mobile/tools/page-replacement-simulator/
“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