Memory & Storage
Explore how computers store and access data — from lightning-fast CPU registers to long-term cloud storage — and understand the memory hierarchy.
The Memory Hierarchy
Not all storage is equal. Computers use a memory hierarchy — layers of storage that trade off speed against capacity and cost. The closer memory is to the CPU, the faster (and smaller) it is.
Think of it like a chef's workspace: ingredients at arm's reach (registers) are fastest, the pantry (RAM) is close by, and the warehouse (disk) holds everything else.
Memory Types (Fastest to Slowest)
- CPU Registers — Tiny, ultra-fast storage built inside the CPU itself. Holds the data currently being processed. Measured in bytes.
- CPU Cache (L1, L2, L3) — Small but very fast memory on or near the CPU chip. Stores frequently used data to avoid fetching from RAM. Measured in KB to MB.
- RAM (Random Access Memory) — Main working memory. Fast but volatile (data is lost when powered off). Typical PCs have 8–64 GB.
- SSD (Solid-State Drive) — Permanent storage using flash memory chips. Much faster than HDDs. No moving parts.
- HDD (Hard Disk Drive) — Permanent storage using magnetic spinning disks. Slower but cheaper per GB.
- Optical / USB — CDs, DVDs, USB flash drives. Portable but slow.
- Cloud Storage — Remote storage on servers accessed over the internet (e.g., Google Drive, Dropbox).
RAM vs ROM
- RAM (Random Access Memory) — Volatile, read/write memory used for running programs. Cleared when you shut down.
- ROM (Read-Only Memory) — Non-volatile memory that stores firmware (e.g., BIOS/UEFI). Data persists permanently.
Virtual Memory
When RAM is full, the operating system uses a section of the hard drive as virtual memory (called the "swap space" or "page file"). This extends available memory but is significantly slower than real RAM.
Storage Interfaces
- SATA — Common interface for HDDs and SSDs
- NVMe (PCIe) — Very fast interface for modern SSDs, significantly faster than SATA
- USB 3.0 / USB-C — For external drives and flash storage
- eMMC — Embedded flash storage found in smartphones and budget tablets
How Files are Stored
When you save a file, the OS writes it to disk in a structured format managed by a file system:
- NTFS — Used by Windows. Supports large files and permissions.
- ext4 — Common Linux file system.
- APFS — Used by macOS and iOS. Optimized for SSDs.
- FAT32 / exFAT — Cross-platform formats used on USB drives.
What's Next?
Learn how the OS manages memory allocation in Operating Systems, or understand how data is organized within those memory locations in Data Structures.