Skip to content
Study Hall
Lesson 2 of 5Hardware, Software and Operating Systems
Unit 2 · Lesson 2 of 5

Memory and Storage

Why one computer needs five different kinds of memory, and how to choose between an SSD and a hard drive.

3 min read9 practice questionsAsk AI about this →

Key things to remember

  1. 1The hierarchy runs registers → L1 → L2 → L3 → RAM → SSD → HDD, getting slower and larger each step.
  2. 2Everything above the SSD line is volatile.
  3. 3RAM is read-write and volatile; ROM is non-volatile and holds firmware.
  4. 4Virtual memory uses drive space as overflow for RAM — it prevents crashes but is about 1000× slower.
  5. 5SSDs beat HDDs most dramatically on random access, not on sequential throughput.
  6. 6RAID provides availability, not backup.

If one kind of memory were fast, huge, cheap and permanent all at once, computers would have exactly one kind. None is. Speed costs money and capacity, and permanence costs speed. So every computer builds a hierarchy: a tiny amount of the fastest memory nearest the CPU, backed by progressively larger and slower layers, each one hiding the slowness of the one below it.

Fast memory is expensive, so computers use a little of it and a lot of the slow kind.Registers< 1 nsbytesL1 / L2 / L3 cache1–20 nsKB – MBRAM (main memory)~60 ns8–32 GBSSD~50 µs0.5–4 TBHDD / cloud~10 msTB+slower →← biggerEverything above the SSD line is volatile: cut the power and it is gone.
Fig 1Speed falls and capacity rises as you go down.

The layers, from the CPU outward

LayerTypical sizeTypical access timeVolatile?
RegistersA few hundred bytes< 1 nsYes
L1 cache32–64 KB per core~1 nsYes
L2 cache256 KB – 2 MB per core~4 nsYes
L3 cache8–64 MB shared~15 nsYes
Main memory (RAM)8–64 GB~60 nsYes
SSD250 GB – 4 TB~50 µsNo
Hard disk1–20 TB~10 msNo
Each step down is roughly an order of magnitude slower and an order of magnitude larger.
The scale is hard to feel
If an L1 cache hit took one second, a RAM access would take about a minute and a hard-disk seek would take four months. That is why the hierarchy exists, and why a program that fits in cache can be many times faster than one that does not.

RAM and ROM

ARAM — random access memory
  • Volatile: contents vanish without power
  • Read and written freely at full speed
  • Holds the OS, running programs and their data
  • DRAM needs constant refreshing; SRAM (used for cache) does not
BROM — read-only memory
  • Non-volatile: keeps contents with no power
  • Written rarely, or never after manufacture
  • Holds firmware — the UEFI/BIOS that starts the machine
  • Modern flash-based ROM can be updated, which is why firmware updates exist
Virtual memory
When RAM fills up, the OS moves the least recently used pages out to a page file (Windows) or swap partition (Linux) on the drive, freeing RAM for what is active. It prevents crashes, but drive access is roughly a thousand times slower than RAM — which is exactly what "thrashing" feels like when a machine with too little RAM grinds to a halt.

Choosing secondary storage

HDD — magnetic plattersmoving head + spinning diskcheap per GB · fragile · slow seeksSSD — NAND flashno moving parts — any cell in the same timefast · silent · limited write cyclesBoth are non-volatile secondary storage. The difference is how a byte is found.
Fig 2A hard drive finds data by moving; an SSD finds it electronically.
HDDSATA SSDNVMe SSD
Sequential read~150 MB/s~550 MB/s3 000–7 000 MB/s
Random accessVery slow (head must move)FastFast
Cost per TBLowestModerateHigher
Shock resistancePoor — moving partsExcellentExcellent
Wear limitMechanical failureFinite write cyclesFinite write cycles
Best useBulk archive, backupsGeneral upgradeOS and demanding applications

The headline sequential figures undersell the difference. What makes an SSD feel transformative is random access: a hard drive has to physically move its head and wait for the platter to rotate under it, which takes milliseconds every time. Booting an OS or launching an application means thousands of small scattered reads, and that is where a drive with no moving parts wins by a factor of a hundred, not a factor of four.

RAID is not a backup
RAID 1 mirrors data across two drives so the system survives one drive failing. It does not protect you from deleting a file, from ransomware, or from a fire — because every change is instantly copied to both drives. A real backup is a separate copy, ideally offline and off-site.

Worked examples

Reveal one step at a time and try to beat it to the next line.

Example 1
A laptop with 8 GB of RAM slows to a crawl when a browser with 40 tabs, a photo editor and a virtual machine are all open. Explain the mechanism, and give two fixes ranked by effectiveness.
Example 2
A computer boots in 90 seconds from a hard drive. Explain why an SSD typically cuts this to under 15 seconds, even though the SSD's sequential speed is only about four times higher.

Where marks get lost

  • Calling RAM "memory" and storage "memory" in the same sentence without distinguishing them.
  • Thinking adding RAM makes the CPU faster. It removes a bottleneck; it does not raise the clock.
  • Believing virtual memory is a substitute for RAM. It prevents out-of-memory crashes at an enormous speed cost.
  • Treating RAID 1 as a backup. It copies deletions and ransomware just as faithfully as it copies real data.
  • Assuming cache can be upgraded. It is fabricated inside the CPU die and is fixed at manufacture.

Flashcards 8

Order the memory hierarchy from fastest
Which layers are volatile?
DRAM vs. SRAM
What is virtual memory?
+ 4 more

Practice

1
Which of these is NOT volatile?
2
A system has plenty of free disk space but only 4 GB of RAM, and slows badly with several apps open. The best fix is:
3
Order these from fastest access time to slowest.
  1. 1L2 cache
  2. 2Hard disk drive
  3. 3Main memory (DRAM)
  4. 4CPU register
4
What is the name for the condition where a system spends most of its time swapping pages instead of running programs?
5
Why does an SSD have a limited lifespan that a hard drive does not share?
6
Which storage choice best suits archiving 12 TB of video that is rarely accessed?
7
If an L1 cache access takes 1 ns and a RAM access takes 60 ns, how many times slower is RAM?
8
Match each memory type to its description.
SRAM
DRAM
Flash (NAND)
ROM
9
A business keeps its only copy of customer records on a RAID 1 array. What risk remains?

Spot a mistake on this page? Let us know