A Unified Framework for Understanding Every Memory Hierarchy Level

Caches and virtual memory appear at first glance to be very different systems, yet both are answering the exact same four fundamental questions. This article shows how those four questions unify block placement, block identification, block replacement, and write handling across every level of the memory hierarchy, from tiny caches to disk-backed virtual memory.

Memory Hierarchy FrameworkBlock Placement and ReplacementWrite Policies

~3 min read · Updated Sep 6, 2026

Why Caches and Virtual Memory Are More Similar Than They Appear

Caching, discussed earlier in this series, and virtual memory, also discussed earlier, might seem like entirely separate topics — one deals with fast SRAM sitting near the processor, the other with translating addresses and swapping data to disk. In reality, both systems are solving the same underlying problem: deciding how to organize a smaller, faster storage layer that holds a useful subset of a larger, slower one. This shared problem can be broken down into exactly four questions.

Question One: Where Can a Block Be Placed?

This question, called Block Placement, asks how much flexibility exists in choosing where a block of data can go in the smaller, faster storage. A direct-mapped cache, discussed earlier regarding cache fundamentals, allows exactly one location per block, while a fully associative scheme allows any location at all, and set-associative designs, discussed earlier when improving cache performance, sit in between. Virtual memory systems, discussed earlier in this series, are typically fully associative at the page level, since the cost of a page fault is high enough that maximum placement flexibility is worth the extra bookkeeping.

Question Two: How Is a Block Found?

This question, called Block Identification, asks how the system determines whether requested data is actually present. Caches use the tag comparison approach discussed earlier in this series, while virtual memory systems use the page table lookup process discussed earlier, both fundamentally serving the same purpose of confirming a match before declaring a hit.

Question Three: What Happens on a Miss?

This question, called Block Replacement, asks which existing block should be evicted to make room for newly needed data when the storage is full. Common policies include replacing the Least Recently Used (LRU) block, based on the temporal locality principle discussed earlier in this series, or simply replacing a block at random, which is cheaper to implement but slightly less effective on average.

Question Four: How Are Writes Handled?

This question, called the Write Policy, asks what happens when a program modifies data that exists in the faster storage layer. Two common approaches exist:

  • Write-Through: every write immediately updates both the faster layer and the slower layer beneath it, keeping them always consistent, at the cost of extra write traffic to the slower layer.
  • Write-Back: a write only updates the faster layer immediately, marking the block as modified, and the change is only propagated down to the slower layer later, when that block eventually needs to be evicted, reducing write traffic at the cost of added bookkeeping complexity.

Why This Unified View Is Useful

Recognizing that every level of the memory hierarchy answers these same four questions, just with different specific tradeoffs suited to that level's relative speed and cost, makes it far easier to understand a new or unfamiliar memory system quickly: rather than learning an entirely new set of concepts, the same four-question framework can simply be applied again, with the specific answers adjusted for that particular level's constraints.

Written & researched by Dr. Shahin Siami

Related Articles

Virtual Memory: Giving Every Program Its Own Private Address Space

Programs behave as if they have access to a huge, private block of memory, even though physical RAM is limited and shared among many running processes. This article explains how virtual memory creates this illusion through address translation, how page tables and the TLB make translation fast, and what happens when needed data is not currently in physical memory.

Continue

Virtual Machines: Running Multiple Isolated Systems on One Computer

A single physical computer can appear to run several completely separate operating systems at once, each unaware of the others' existence. This article explains what a virtual machine actually is, how a hypervisor manages this illusion, and why this technology matters for both server consolidation and system security.

Continue

Dependable Memory: How Hardware Detects and Corrects Data Errors

Memory hardware is not perfectly reliable; electrical noise and physical defects can silently flip stored bits. This article explains how error detection and correction codes let hardware notice, and in many cases automatically fix, these corrupted values before they cause incorrect program behavior.

Continue

Measuring and Improving Cache Performance

Not all cache misses are the same, and understanding their causes is the first step toward improving performance. This article covers how to calculate the real performance impact of caching using miss rate and miss penalty, classifies the three common causes of cache misses, and explains practical strategies for reducing each type.

Continue

Cache Fundamentals: How Small, Fast Memory Predicts What You Need Next

A cache works because programs tend to access the same or nearby data repeatedly rather than randomly. This article explains the principle of locality that makes caching effective, how a direct-mapped cache locates data using an address, and what happens on a cache hit versus a cache miss.

Continue

The Memory Hierarchy: Why Computers Use Several Kinds of Memory

No single memory technology is simultaneously fast, large, and cheap. This article introduces the concept of a memory hierarchy that combines several different memory technologies to approximate the speed of the fastest one at the cost of the cheapest, then walks through the core technologies that make up each level.

Continue