Memory Hierarchy: Speed vs Cost vs Size
Why does your laptop have a 16 GB RAM stick AND a 1 TB SSD AND tiny CPU caches? Why not just one giant fast memory? Computer architects answered this with the memory hierarchy โ a pyramid that trades speed for size.
Definition: A memory hierarchy is the layered organisation of storage in a computer system, arranged so that the fastest, costliest and smallest memory sits closest to the CPU, while slower, cheaper and larger memory sits farther away.
The five levels โ fast to slow
From fastest, costliest, smallest down to slowest, cheapest, largest:
- Registers โ built right inside the CPU; access time is a fraction of a nanosecond.
- Cache memory โ SRAM, very fast, organised as L1 < L2 < L3 (L1 the fastest and smallest, L3 the largest and slowest of the three).
- Primary memory (Main memory / RAM) โ DRAM; the workspace where running programs and current data live. Volatile.
- Secondary memory โ SSDs and HDDs; non-volatile, stores files, OS, and installed software.
- Tertiary / off-line memory โ optical discs (CD, DVD, Blu-ray), magnetic tapes; used for backups and archiving.
Memory aid: "Real Cats Run So Tirelessly" โ Registers, Cache, RAM, Secondary, Tertiary.
The golden rule of the hierarchy
As you move down the pyramid, three things happen together:
- Speed decreases (access time goes up).
- Cost per bit decreases (you can afford more of it).
- Capacity increases (each level is bigger than the one above).
Roughly: registers are measured in bytes, cache in kilobytes-to-megabytes, RAM in gigabytes, SSDs/HDDs in hundreds of gigabytes-to-terabytes, and tape backups in many terabytes. The price-per-GB drops by orders of magnitude with each step.
Why this design? The locality principle
Programs do not access memory randomly. They show temporal locality (a recently used address is likely to be reused soon โ think loop variables) and spatial locality (addresses near a recently used one are likely to be touched next โ think array elements). A small fast cache that automatically stores the most-used data behaves, on average, almost as fast as if all of RAM were that fast โ at a tiny fraction of the cost.
Why it matters: This single idea is the reason a modern PC costing under โน50,000 feels faster than a 1990s mainframe. SBI PO, IBPS PO, RRB NTPC and most computer-awareness sections ask ordering questions ("Which is faster: cache or RAM?", "Arrange in increasing order of speed"). One mnemonic and one rule will let you answer them in seconds.
Cache levels โ L1, L2, L3
- L1 cache โ split into instruction cache and data cache; typically 32โ64 KB per CPU core; the fastest.
- L2 cache โ larger (256 KB to a few MB) and a little slower; usually private to each core.
- L3 cache โ shared by all cores on a chip; can be 4 MB to 64+ MB; slower than L1/L2 but still much faster than RAM.
Remember: L1 is fastest and smallest; L3 is largest and slowest of the three.
Direct access โ what the CPU can really see
The CPU can directly read from and write to only registers, cache, and main memory (RAM). Anything stored on the SSD, HDD, DVD or tape must first be loaded into RAM before the CPU can work on it. That is why opening a large file feels slow at first (loading from secondary storage) but smooth afterwards (now in RAM/cache).
Real-world example: When you double-click a movie file, the operating system requests the data from the SSD, copies it into RAM, and the CPU then processes it โ pulling small chunks into cache as needed. If the SSD were directly used by the CPU, your movie would play frame-by-frame, every few seconds. The hierarchy hides this slowness through caching.
Common misconception: "Cache is part of RAM." It is not. Cache is SRAM built into the CPU package (in L1/L2/L3 layers), while RAM is DRAM sitting on separate sticks plugged into the motherboard. SRAM is faster and costlier per bit; DRAM is cheaper and denser.
Question: A student writes that the order from fastest to slowest is: Registers > RAM > Cache > SSD > HDD > DVD. What is wrong?
Solution:
Step 1: Recall the golden rule โ higher on the pyramid = faster.
Step 2: Cache lies BETWEEN registers and RAM, not below RAM. Cache is faster than RAM.
Step 3: Within secondary memory, SSD is faster than HDD.
Conclusion: The correct order is Registers > Cache (L1 > L2 > L3) > RAM > SSD > HDD > DVD/Tape.
| Level | Type | Typical size | Volatile? | CPU direct access? |
|---|---|---|---|---|
| Registers | SRAM (inside CPU) | bytes | yes | yes |
| Cache (L1/L2/L3) | SRAM | KB to tens of MB | yes | yes |
| Primary (RAM) | DRAM | GB | yes | yes |
| Secondary (SSD/HDD) | Flash / Magnetic | hundreds of GB to TB | no | no |
| Tertiary (DVD/Tape) | Optical / Magnetic | GB to many TB | no | no |
- โ- Memory hierarchy ranks storage from fastest+costliest+smallest to slowest+cheapest+largest.
- โ- Order (fast โ slow): Registers > Cache > Primary (RAM) > Secondary (SSD/HDD) > Tertiary (DVD/Tape).
- โ- L1 < L2 < L3 in size; L1 is the fastest of the three caches.
- โ- Primary memory is volatile; secondary and tertiary are non-volatile.
- โ- CPU can directly access only Registers, Cache and RAM โ never secondary storage.
- โ- Going down the hierarchy: speed โ, cost/bit โ, capacity โ.
- โ- The locality principle (temporal + spatial) makes caching efficient.
"Real Cats Run So Tirelessly" โ Registers, Cache, RAM (primary), Secondary, Tertiary.
For cost-speed rule: "HFCS" โ Higher = Faster, Costlier, Smaller.
- โ- The memory hierarchy uses speed-cost trade-offs to give cheap, fast-feeling computers.
- โ- Registers are fastest; tertiary storage is slowest and cheapest.
- โ- Cache (SRAM) bridges the CPU-RAM speed gap.
- โ- CPU cannot access secondary storage directly; data must first move to RAM.
RAM vs ROM, Volatile vs Non-volatile
RAM (Random Access Memory) = volatile (data lost on power-off), read/write, working memory. Types: DRAM (needs constant refresh, used as main memory, cheap) and SRAM (no refresh, used as cache, fast/costly). ROM (Read Only Memory) = non-volatile, stores BIOS/firmware. ROM types: PROM (programmed once), EPROM (erased by UV light), EEPROM (electrically erasable โ used in flash). Memory aid: 'EEPROM = Electrically Erasable'. Cache and RAM are volatile; ROM, HDD, SSD, flash are non-volatile. SBI PO trap: SRAM is faster than DRAM but DRAM is denser/cheaper. Flash memory (USB drives, SSD) is a type of EEPROM.
Storage Unit Conversions (Memory Math)
Your phone says "16 GB free", your pen-drive label reads "32 GB", and the SBI PO question paper expects you to convert one into the other in five seconds flat. Storage units look harmless until you are inside a tight time budget โ that is when a clean mental model of the byte ladder becomes worth real marks.
Definition: A bit is the smallest unit of digital information โ a single 0 or 1.
Definition: A byte is a group of 8 bits, and is the standard unit a computer uses to store one character of text.
Definition: A nibble is half a byte โ 4 bits โ useful in hexadecimal representation.
Why everything is built on 8 bits
The number 8 is not random. Early computer designers chose it because 8 bits give 2^8 = 256 distinct combinations โ enough to encode every English letter (upper and lower case), every digit, common punctuation and control codes, with room to spare. That decision froze itself into hardware, memory chips, file formats, and exam syllabi. So whenever a question mentions "characters", "ASCII", or "text size", remember that one byte equals one character of plain English text.
The full ladder you must memorise
The hierarchy in ascending order is:
bit โ Nibble โ Byte โ KB โ MB โ GB โ TB โ PB โ EB โ ZB โ YB
(KB = kilobyte, MB = megabyte, GB = gigabyte, TB = terabyte, PB = petabyte, EB = exabyte, ZB = zettabyte, YB = yottabyte.) Each step climbs by 1024 (which is 2^10) in the binary system the computer actually uses, or by 1000 in the decimal system used in marketing and on hard-disk labels. Banking exams almost always use the 1024 convention unless the question says otherwise.
Why 1024 and not a round 1000? Because computers count in powers of 2. The closest power of 2 to 1000 is 2^10 = 1024, so engineers adopted it as "one thousand-ish" for binary memory. This is exactly why your 1 TB hard disk shows up in Windows as roughly 931 GB โ Windows divides by 1024 thrice while the manufacturer divided by 1000 thrice.
| Unit | Symbol | Binary value | Decimal value |
|---|---|---|---|
| Kilobyte | KB | 1024 B | 1000 B |
| Megabyte | MB | 1024 KB | 1000 KB |
| Gigabyte | GB | 1024 MB | 1000 MB |
| Terabyte | TB | 1024 GB | 1000 GB |
| Petabyte | PB | 1024 TB | 1000 TB |
| Exabyte | EB | 1024 PB | 1000 PB |
| Zettabyte | ZB | 1024 EB | 1000 EB |
| Yottabyte | YB | 1024 ZB | 1000 ZB |
The numeric trick examiners love
Going down the ladder (bigger โ smaller) means multiply by 1024. Going up (smaller โ bigger) means divide by 1024. So:
- GB โ MB โ KB โ B: multiply by 1024 at each step
- B โ KB โ MB โ GB: divide by 1024 at each step
For SBI PO, a clean shortcut is to convert in one jump. Two steps down equals multiplication by 1024 ร 1024 โ 10,48,576 (roughly one million). So 1 GB is approximately one billion bytes (10^9), 1 TB is about one trillion bytes (10^12). This rough-approximation trick lets you eliminate clearly wrong options without exact computation.
Encoding standards โ how characters become bytes
Definition: ASCII (American Standard Code for Information Interchange) is the original character encoding standard that uses 7 bits per character.
Seven bits give 2^7 = 128 characters โ enough for English alphabet (upper + lower), digits 0โ9, punctuation, and control characters like Enter or Tab. Extended ASCII uses the 8th bit too, giving 256 characters and accommodating accented Latin letters, line-drawing symbols, and other regional marks.
Definition: Unicode is a universal encoding designed for every script on Earth, including Devanagari (Hindi), Tamil, Bengali, Chinese, Arabic and emoji.
Unicode comes in several encoding forms โ UTF-8, UTF-16, UTF-32. Basic 16-bit Unicode allows 2^16 = 65,536 characters, which is why your WhatsApp can send "เคจเคฎเคธเฅเคคเฅ" or a laughing emoji as easily as "Hello". When a question contrasts ASCII and Unicode, the load-bearing fact is: ASCII = English only, Unicode = global scripts including Indian languages.
Why it matters: Banking IT roles and digital banking depend on reliable character storage. If your bank's database stored your name "Anushka" in plain ASCII, a customer named "เค เคจเฅเคทเฅเคเคพ" would corrupt instantly. So every modern Indian banking system uses Unicode under the hood โ and the SBI PO syllabus tests whether you know which encoding supports Hindi.
Real-world example
Your Aadhaar PDF download is usually around 200 KB. That means it is using roughly 200 ร 1024 = 2,04,800 bytes โ and since one ASCII byte = one character, the file holds the equivalent of nearly two lakh English characters worth of data (text plus compressed image data). A 4 GB movie file is 4 ร 1024 ร 1024 ร 1024 โ 4.29 billion bytes. A 1 TB external hard disk (sold on Flipkart) can hold roughly 250 such movies. Knowing the ladder lets you sanity-check storage claims at a glance.
Worked example
Question: A photograph is 3 MB in size. How many such photos can be stored on a 6 GB SD card? (Use 1 GB = 1024 MB.)
Solution:
Step 1: Convert the SD card capacity into MB. 6 GB = 6 ร 1024 MB = 6144 MB.
Step 2: Divide total capacity by the size of one photo. Number of photos = 6144 / 3 = 2048 photos.
Conclusion: The SD card can store 2,048 photographs of 3 MB each.
Common misconception
Many candidates believe "1 KB = 1000 bytes" because the prefix "kilo" means thousand in the metric system. In the strict computing sense used by exams, 1 KB = 1024 bytes (a binary kilobyte, sometimes written as KiB). The 1000-based version is used by storage manufacturers and network speeds (Mbps). Read the question stem carefully โ if it specifies "decimal" or "SI units", use 1000; otherwise default to 1024.
A second misconception: that "1 character = 1 bit". No โ one bit is just a single 0 or 1, far too little to encode even the letter "A". One character of English text always equals one byte (8 bits) in ASCII.
- โ- 1 Byte = 8 bits; 1 Nibble = 4 bits; ASCII byte = one English character.
- โ- Ladder: bit โ Byte โ KB โ MB โ GB โ TB โ PB โ EB โ ZB โ YB.
- โ- Binary step = 1024 (2^10); decimal step = 1000.
- โ- GB โ MB โ KB: multiply by 1024 at each step (going down).
- โ- ASCII = 7 bits = 128 chars; Extended ASCII = 8 bits = 256 chars; Unicode = 16 bits = 65,536 chars (supports Hindi, emoji).
- โ- 1 KB = 1024 B; 1 MB = 1024 KB; 1 GB = 1024 MB; 1 TB = 1024 GB.
- โ- Hard-disk marketing uses 1000-based units, so a 1 TB disk shows ~931 GB in Windows.
- โ- Two steps down = roughly one million (used for fast option elimination).
Order mnemonic: "Kind Men Give Tasty Pizza Every Zomato Year" โ K, M, G, T, P, E, Z, Y โ KB, MB, GB, TB, PB, EB, ZB, YB.
Conversion direction: "Down means ร1024, Up means รท1024."
- โ- One byte equals eight bits and stores one ASCII character.
- โ- Each step on the ladder is 1024 in binary, 1000 in decimal.
- โ- ASCII handles English; Unicode handles Hindi and the world.
- โ- Multiply by 1024 when descending the ladder; divide when ascending.
Computer Memory & Storage โ Flashcards
Cover the answer, recall, then check. 12 cards on memory types and units for SBI PO.
Q1. State the memory hierarchy from fastest/costliest to slowest/cheapest.
A1. Registers โ Cache (L1/L2/L3) โ Primary memory (RAM) โ Secondary storage (HDD/SSD) โ Tertiary (tape/optical).
Q2. Difference between RAM and ROM in one line.
A2. RAM is volatile read/write working memory; ROM is non-volatile permanent memory that stores start-up firmware (BIOS).
Q3. SRAM vs DRAM โ which is used for cache and which for main memory?
A3. SRAM (static, faster, no refresh) = cache; DRAM (dynamic, needs refresh, cheaper) = main memory/RAM.
Q4. Name the four common ROM types.
A4. PROM, EPROM (erased by UV light), EEPROM (electrically erasable), and Mask ROM.
Q5. How many bytes are in 1 KB, and why not 1000?
A5. 1 KB = 1024 bytes = 2ยนโฐ, because computers count in powers of 2.
Q6. Give the storage-unit ladder from smallest to TB.
A6. Bit < Nibble (4 bits) < Byte (8 bits) < KB < MB < GB < TB (each ร1024).
Q7. Where is cache memory located and why is it used?
A7. Between the CPU and RAM; it holds frequently used data to reduce the CPU's wait time (faster than RAM).
Q8. Which is the fastest memory in a computer?
A8. Registers, located inside the CPU.
Q9. Approximate capacities: CD, DVD, Blu-ray (single layer)?
A9. CD โ 700 MB, DVD โ 4.7 GB, Blu-ray โ 25 GB.
Q10. What is virtual memory?
A10. A technique that uses part of secondary storage (HDD/SSD) as an extension of RAM when RAM is full.
Q11. Is a pen drive / SSD volatile or non-volatile, and what memory does it use?
A11. Non-volatile; both use flash memory (EEPROM-based) that retains data without power.
Q12. How many bits in a nibble and a byte?
A12. Nibble = 4 bits; Byte = 8 bits.
Computer Memory & Storage Hierarchy โ Summary
Memory questions are a banking-exam staple: the "how many bytes in a KB" and "RAM vs ROM" one-liners appear in nearly every Computer section, and in SBI PO they sit inside the Reasoning & Computer Aptitude paper. This is high-yield recall โ memorise the ladder and the volatile/non-volatile split and you never lose these marks.
The memory hierarchy
From fastest, smallest, costliest at the top to slowest, largest, cheapest at the bottom:
Registers โ Cache (L1/L2/L3) โ RAM (main) โ Secondary (HDD/SSD) โ Tertiary (tape/optical).
- Registers โ fastest, inside the CPU (MAR, MDR, PC, IR, Accumulator).
- Cache โ sits between CPU and RAM; SRAM-based; L1 smallest & fastest.
- RAM (Random Access Memory) โ volatile working memory. SRAM (static, no refresh, cache) vs DRAM (dynamic, needs refresh, main memory).
- ROM (Read Only Memory) โ non-volatile, stores BIOS/firmware: PROM, EPROM (UV-erased), EEPROM (electrically erased), Mask ROM.
Storage units
| Unit | Size |
|---|---|
| Nibble | 4 bits |
| Byte | 8 bits |
| 1 KB | 1024 bytes (2ยนโฐ) |
| 1 MB | 1024 KB |
| 1 GB | 1024 MB |
| 1 TB | 1024 GB |
| 1 PB | 1024 TB |
Media capacities: CD โ 700 MB, DVD โ 4.7 GB, Blu-ray โ 25 GB.
Exam Tricks & Tips
- ๐ฏ Volatile = RAM only; everything permanent (ROM, HDD, SSD, pen drive, CD) is non-volatile.
- ๐ฏ Unit ladder mnemonic: "Nobody Bytes Karim's Mango, Grab The Piece" = Nibble-Byte-KB-MB-GB-TB-PB.
- ๐ฏ SRAM = Speedy (cache); DRAM = Dense/cheap (main memory).
- ๐ฏ Access-speed order: Register < Cache < RAM < HDD (smaller number = faster).
- ๐ฏ E-E-PROM = Electrically Erasable โ the double-E means erased by electricity, not UV (that's EPROM).
- โ Common mistake: writing 1 KB = 1000 bytes. In computer memory it is 1024 (a power of 2); 1000 is only used loosely for disk marketing.
Expected exam pattern
Direct MCQs: "1 KB = ? bytes", "Which memory is volatile?", "Cache lies between which two?", "EPROM is erased by?" One or two questions, pure recall.
Quick recap
Hierarchy RegisterโCacheโRAMโSecondary; RAM volatile, ROM/flash non-volatile; SRAM=cache, DRAM=main; 1 KB = 1024 bytes; CD 700 MB / DVD 4.7 GB / Blu-ray 25 GB.
Computer Memory & Storage Hierarchy โ Worked Example
Worked Example
Problem: Solved awareness question: Arrange registers, cache, main memory (RAM) and secondary storage (hard disk) from fastest to slowest, and state how speed relates to cost and capacity.
Solution:
Order by proximity to the CPU (closer = faster).
- Registers โ inside the CPU, fastest, smallest.
- Cache โ very fast, small, sits between CPU and RAM.
- Main memory (RAM) โ fast, larger, volatile working memory.
- Secondary storage (hard disk/SSD) โ slowest of these, largest, non-volatile.
Relationship: as you move down the hierarchy, speed decreases while capacity increases and cost per byte decreases.
Answer: Fastest to slowest: registers โ cache โ RAM โ secondary storage; lower levels are slower but cheaper and larger.
- โ- Memory hierarchy (fastโslow): registers, cache, RAM, secondary storage.
- โ- Going down the hierarchy: slower, but larger capacity and lower cost per byte.
- โ- Faster memory is costlier per byte, so systems use small fast + large slow layers together.