AiTechWorlds
AiTechWorlds
Imagine you are sitting at a desk to write a report. The papers you are actively reading and writing are spread across your desk surface — you can grab any of them instantly. Behind you is a large filing cabinet where finished documents are stored permanently. And stuck right in front of your monitor are a few sticky notes with the three numbers you keep needing every five minutes.
That desk is your computer's memory system. The papers on the surface are RAM. The filing cabinet is the hard drive. And those sticky notes? That is cache. Each layer exists because of a fundamental tradeoff: speed costs money, and capacity costs space. No single memory type can be fast, cheap, and large at the same time — so modern computers use all of them together, each playing its role.
Every operation a CPU performs requires data — and the CPU is extraordinarily fast. A modern processor can execute billions of instructions per second. If it had to wait for data from a spinning hard drive every time it needed a number, it would spend 99% of its time just waiting. The solution is a memory hierarchy: a layered system where the fastest (and most expensive) storage sits closest to the processor, and the slowest (but cheapest and largest) sits furthest away.
The golden rule of memory: The faster it is, the smaller and more expensive it is. The hierarchy exists to give programs the illusion of unlimited fast memory.
RAM is the computer's working memory. When you open a browser, a document, or a game, that program is loaded from storage into RAM so the CPU can access it quickly. The name "random access" means any memory location can be reached in the same amount of time — there is no need to scan through data sequentially like a tape.
RAM is volatile. The moment power is cut, every bit of data in RAM vanishes. This is why you lose unsaved work when a computer crashes unexpectedly.
Modern desktop and laptop RAM uses DDR (Double Data Rate) technology. In 2026, the two dominant standards are:
| Standard | Typical Speed | Bandwidth | Typical Voltage |
|---|---|---|---|
| DDR4 | 2133–3200 MHz | Up to 51.2 GB/s | 1.2V |
| DDR5 | 4800–6400 MHz | Up to 102.4 GB/s | 1.1V |
DDR5 doubles the bandwidth of DDR4 while using slightly less power. It became mainstream in 2022 and is now standard on high-end platforms.
Desktop RAM comes as DIMM (Dual Inline Memory Module) sticks — flat circuit boards about 13 cm long with gold contacts along the bottom edge. Laptops use the smaller SO-DIMM form factor. Mobile devices and ultrabooks use LPDDR (Low Power DDR), soldered directly onto the motherboard to save space and reduce power consumption.
| Amount | Typical Use Case |
|---|---|
| 8 GB | Basic browsing, office work, light multitasking |
| 16 GB | Standard user, coding, video calls, moderate gaming |
| 32 GB | Power user, video editing, heavy multitasking |
| 64 GB+ | Workstation, 3D rendering, machine learning, server tasks |
While RAM loses data without power, ROM is non-volatile — it retains its contents permanently. As the name suggests, data stored in ROM is primarily read, not written.
The most important use of ROM in modern computers is storing the BIOS (Basic Input/Output System) or its modern successor, UEFI (Unified Extensible Firmware Interface). This is the first code that runs when a computer powers on — it initialises hardware, checks that components are working, and hands control over to the operating system.
Modern ROM is not truly "read only" in a strict sense. Several types can be updated:
Flash ROM is also the technology inside USB drives, SSDs, and memory cards. The same principle — non-volatile, electrically rewritable — just at vastly different scales.
RAM is roughly 100 times slower than CPU registers (the tiny storage spaces built directly into the processor). Cache memory exists to bridge this gap. It is a small, ultra-fast memory built directly into the CPU chip itself.
The processor checks cache before going to RAM. If the data it needs is already in cache (a cache hit), it retrieves it in nanoseconds. If not (a cache miss), it fetches from RAM and also stores a copy in cache for next time.
Modern CPUs use three levels of cache:
| Level | Speed | Size | Location |
|---|---|---|---|
| L1 | ~1 ns | 32–64 KB per core | Inside each CPU core |
| L2 | ~5 ns | 256 KB–1 MB per core | Inside each CPU core |
| L3 | ~20 ns | 8–64 MB total | Shared across all cores |
L1 is the fastest and smallest — it holds the instructions and data a core is using right now. L2 is slightly larger and acts as a buffer. L3 is the largest level and is shared between all cores, allowing them to pass data efficiently without going all the way out to RAM.
A practical example: the AMD Ryzen 9 7950X has 80 MB of L3 cache. The Intel Core i9-13900K has 36 MB. Cache size is a major factor in real-world CPU performance.
What happens when your programs need more RAM than you physically have? The operating system turns to the hard drive or SSD as an emergency overflow area. This is called virtual memory, implemented through a page file (Windows) or swap partition (Linux/macOS).
The OS moves the least-recently-used blocks of RAM data (called pages) to the disk, freeing up physical RAM for the programs that need it most. When those pages are needed again, they are swapped back in.
The cost is enormous in performance terms. RAM access takes ~100 nanoseconds. SSD access takes ~50 microseconds — 500 times slower. HDD access takes ~10 milliseconds — 100,000 times slower than RAM. When a system is heavily relying on virtual memory, you will notice the computer slow to a crawl. This is called thrashing.
Picture a professional chef in a kitchen:
A great chef pre-stages ingredients (cache), keeps the fridge stocked (RAM), and only sends someone to the warehouse (HDD) for things not immediately needed. A slow kitchen is one where the chef constantly runs to the warehouse mid-service.
| Memory Type | Access Time | Typical Capacity | Volatile? |
|---|---|---|---|
| CPU Registers | 0.3 ns | Bytes (< 1 KB) | Yes |
| L1 Cache | 1 ns | 32–64 KB | Yes |
| L2 Cache | 5 ns | 256 KB–1 MB | Yes |
| L3 Cache | 20 ns | 8–64 MB | Yes |
| RAM (DDR5) | 100 ns | 8–128 GB | Yes |
| NVMe SSD | 50 µs | 256 GB–8 TB | No |
| SATA SSD | 100 µs | 256 GB–4 TB | No |
| HDD | 10 ms | 1–20 TB | No |
Understanding this hierarchy is the foundation of understanding why computers behave the way they do. When a game stutters after sitting minimised, it is because the OS swapped it to virtual memory. When a program launches faster the second time, it is because data is already in cache. Memory is not one thing — it is a carefully orchestrated team.
Get this course's notes on Telegram!
Free cheat sheets, summaries & practice exercises