Concept Guide · Memory
Primary vs Secondary Memory
Cache · DRAM · SRAM · Why Videos Buffer
Computers and phones keep data in layers — from ultra-fast cache next to the CPU, down to slow but huge storage. The same idea explains why a video hesitates when you open it or scrub the timeline, but plays smoothly once it starts.
Primary Memory
Secondary Memory
Cache / SRAM
DRAM
Video Buffering
1. The memory pyramid
Every useful system balances speed, size, and cost. Fast memory is expensive and small. Huge memory is cheap and slow. So designers stack layers:
CPU registersFastest · tiny · inside the core
Cache (L1 / L2 / L3) — SRAMVery fast · small · near the CPU
Main memory — DRAM (RAM)Fast enough · gigabytes · working set
Secondary storage — SSD / HDD / FlashSlower · huge · permanent files
Rule of thumb: data the CPU needs right now should already be in a fast layer. Everything else can live farther away until it is needed.
2. Primary vs secondary memory
Primary memory
What the CPU uses while a program is running: registers, cache, and main RAM (DRAM). Usually volatile — contents vanish when power is cut. Goal: keep the processor fed with instructions and data.
Secondary memory
Long-term storage: SSD, HDD, eMMC, microSD, USB drive. Non-volatile — files survive reboot. Goal: hold apps, photos, videos, OS images cheaply and in large capacity.
| Aspect | Primary (RAM / cache) | Secondary (SSD / HDD) |
| Speed | ns to tens of ns | µs to ms (much slower) |
| Size | MB–tens of GB typical | Hundreds of GB–TBs |
| Cost / bit | High | Low |
| Power off | Data lost (volatile) | Data kept (non-volatile) |
| CPU access | Direct / almost direct | Through OS + controllers |
When you “open” a video file, the OS must move pieces from secondary storage (or the network) into primary memory before the player can decode frames smoothly.
3. Cache, SRAM, and DRAM — what lives “inside memory”
DRAM — main memory (your “RAM”)
DRAM (Dynamic RAM) stores each bit as charge on a tiny capacitor. It is dense and affordable, so phones and PCs use gigabytes of it for the working set of apps. Capacitors leak, so DRAM needs periodic refresh. Latency is higher than cache — often tens to ~100+ ns from the CPU’s point of view.
SRAM — what caches are made of
SRAM (Static RAM) stores bits in transistor latch cells (classically a 6T cell). No refresh, much faster access, but each bit needs more silicon area — so it is expensive. That is why SRAM is used for CPU caches and on-chip buffers, not for your entire 16 GB of system memory.
Cache — the “recent stuff” shelf
Cache is a small SRAM store between CPU and DRAM. It keeps recently used lines of data/instructions because programs reuse data (temporal locality) and touch nearby addresses (spatial locality).
- L1 — smallest, fastest, often private per core
- L2 — larger, a bit slower
- L3 — largest on-chip shared cache on many CPUs
A cache hit means data was already nearby → fast. A cache miss means fetch from a slower layer → stall / wait.
| SRAM (cache) | DRAM (main RAM) |
| Cell idea | Transistor latch | 1T + capacitor |
| Speed | Very fast | Slower |
| Density | Low | High |
| Refresh | Not needed | Required |
| Typical use | L1/L2/L3 cache, register files | System RAM (DDR) |
For transistor-level and Verilog RAM details, see the deeper guide: SRAM vs DRAM & Memory Arrays.
4. Why opening a video takes time — but playing feels smooth
Have you noticed: tapping a video shows a spinner, then playback is smooth… until you drag the timeline far away and buffering returns? That is memory hierarchy + buffering in everyday life.
Opening the video (cold start)
- Find the file / stream — OS or app contacts storage or a CDN. Secondary storage / network is slow compared with RAM.
- Read the header — container metadata (duration, codecs, keyframe index) must be loaded before decode can start.
- Fill a play buffer — the player downloads or reads a few seconds of upcoming audio/video into RAM. Until that buffer is “warm,” you wait.
That wait is not “the video is hard.” It is latency to fill the first buffer from a slow source into fast memory.
While playing (steady state)
Once a cushion of future frames sits in RAM (and often in the browser/player cache), the decoder reads ahead. As long as new data arrives faster than you consume it, playback stays smooth — like a CPU hitting cache and DRAM for a working set that is already local.
Seeking / shifting time (why buffering comes back)
When you jump from 0:30 to 12:45:
- The buffered data around 0:30 is mostly useless for 12:45.
- The player must fetch a new segment (often from the nearest keyframe) from disk or the network.
- Until the new buffer fills, you see buffering — the software equivalent of a big cache miss.
Small scrub nearby may stay smooth (data still in buffer). A big jump almost always misses and reloads. Live streams and slow Wi‑Fi make misses more painful.
5. Map the video story back to hardware
| Video experience | Memory idea |
| Video file on phone storage / YouTube servers | Secondary memory / remote store |
| Player buffer in RAM | Primary memory (DRAM) |
| Decoder / CPU working on current frames | Cache + registers (SRAM near CPU) |
| Opening spinner | Cold miss — fill buffer from slow tier |
| Smooth playback | Hits — data already in fast buffer |
| Seek → buffering again | Miss — new address range not cached |
Engineers design CPUs the same way video apps design players: prefetch what you will need next, keep a buffer, and accept that random jumps are expensive.
6. FAQ
Is cache the same as RAM?
No. “RAM” usually means main DRAM. Cache is a smaller, faster SRAM layer on (or very near) the CPU that holds copies of recently used DRAM contents.
Is SSD primary memory?
No. SSD is secondary (or “storage”). It is non-volatile and much slower than DRAM. The OS may use some SSD as swap, but that is still not as fast as true RAM.
Why not make all memory SRAM?
Cost and area. SRAM needs more transistors per bit. Building 16 GB of SRAM like a DDR stick would be enormous and extremely expensive. Hierarchy is the practical compromise.
Does clearing “cache” in phone settings wipe SRAM?
Usually no — that clears app file caches on flash storage (secondary), not the CPU’s L1/L2/L3 SRAM caches, which are managed automatically by hardware.