When a running process references a page that isn't currently in physical memory, the operating system takes a page fault and must load it — evicting another resident page if all frames are full. Which page gets evicted is decided by a page-replacement policy. This simulation runs the same request sequence through four classic policies at once, one row of memory frames per policy, so you can watch their eviction decisions and fault counts diverge in real time.
Each row of boxes is one policy's memory frames; the number on a box is the resident page. A box flashes green on a hit and orange on a fault when a new page is loaded. The vertical bar at the end of each row grows with that policy's running fault count, so the row that grows tallest is currently faulting the most.
A shared stream of memory-page requests is fed simultaneously into four rows of memory frames, one per replacement policy, so you can watch FIFO, LRU, clock and optimal make different eviction calls on the exact same sequence.
Each row runs the identical request sequence but keeps its own eviction logic. A box flashes orange on a page fault and green on a hit, and each row's bar grows with its running fault count — making the gap between a cheap heuristic and the optimal bound visible at a glance.
Set the frame count and feed speed, and pick a request pattern — including a Belady worst-case sequence that can make FIFO get worse with more frames. Generate a new sequence any time and compare fault totals across policies.
The optimal policy (Belady's MIN) is provably fault-minimal but needs to know the future — it's unimplementable in a real OS and exists purely as the yardstick every practical algorithm is measured against.