A computer keeps data and instructions in several kinds of memory at once. They differ in four ways that questions keep returning to: speed, capacity, cost per byte and whether the contents survive a power cut (volatility). The fastest memory is the smallest and most expensive; the largest is the slowest and cheapest.
From the CPU outwards, the levels are:
- Registers: tiny storage on the CPU chip itself.
- Cache: very fast memory between the CPU and main memory.
- Primary memory: RAM, the working memory, plus ROM for fixed startup code.
- Secondary memory: hard disks, SSDs, optical discs, memory cards and pen drives.
When people talk about a computer's "memory", they usually mean primary memory. Secondary memory is more often called storage.