Primary storage: RAM, ROM, virtual memory and cache
Primary storage is memory the CPU can access directly and immediately. OCR J277 Paper 1 regularly tests the differences between RAM and ROM, and the need for primary storage.
Why is primary storage needed?
The CPU can only directly access data and instructions held in primary storage (RAM). Secondary storage (hard disks, SSDs) is too slow for direct CPU access — data must be loaded into RAM first before the CPU can process it.
- Programs run from RAM.
- Currently open files are in RAM.
- The operating system kernel runs from RAM (part of it may be in ROM on embedded devices).
RAM (Random Access Memory)
| Property | Detail |
|---|---|
| Volatile | Contents lost when power is removed |
| Read/write | Can be written to and read from repeatedly |
| Speed | Fast (much faster than secondary storage) |
| Capacity | Typically 4 GB – 64 GB in modern computers |
| Purpose | Holds currently running programs and open data |
- If a computer has more RAM, more programs can run simultaneously without slowing down.
- When RAM is full, the computer uses virtual memory (see below).
ROM (Read-Only Memory)
| Property | Detail |
|---|---|
| Non-volatile | Contents are retained when power is removed |
| Read-only | Cannot be written to under normal operation |
| Speed | Fast |
| Capacity | Very small (kilobytes to a few megabytes) |
| Purpose | Stores the BIOS/firmware — the startup instructions that run before the OS loads |
- ROM is important because the CPU needs instructions immediately on power-up, before any OS is loaded.
- Modern devices may use Flash ROM (EEPROM) which can be updated via firmware updates.
Virtual memory
Virtual memory is a section of secondary storage (e.g. part of the hard disk or SSD) used as an extension of RAM when RAM is full.
How it works
- When RAM is full and a new program is needed, the OS moves the least-recently-used pages of RAM to a page file (swap file) on disk.
- This frees up space in RAM for the new program.
- When the swapped-out data is needed again, it is moved back into RAM (possibly swapping out something else).
Effect on performance
- Virtual memory is much slower than RAM (disk access is ~100,000× slower).
- Excessive use of virtual memory causes thrashing — the system spends most of its time swapping data in and out instead of processing.
- Adding more RAM reduces reliance on virtual memory.
Cache (role in primary storage)
Cache is a very small, very fast type of primary memory built into or near the CPU.
- Sits between the CPU and RAM in the memory hierarchy.
- Stores copies of frequently accessed data/instructions.
- Purpose: reduces the number of times the CPU must wait for RAM access.
Memory hierarchy summary
| Level | Speed | Capacity | Cost per GB |
|---|---|---|---|
| Registers | Fastest | Bytes | — (in CPU) |
| Cache (L1/L2/L3) | Very fast | KB–MB | Very high |
| RAM | Fast | GB | High |
| Virtual memory | Slow | GB (disk) | Low |
| Secondary storage | Slowest | TB | Low |
Common OCR exam mistakes
- Saying ROM is "read-only because it stores programs" — RAM also stores programs. ROM is read-only because it retains data without power and stores startup instructions.
- Saying virtual memory is "extra RAM" — it is disk space used to simulate RAM; it is much slower.
- Forgetting that RAM is volatile — this is a key distinction often tested.
- Confusing cache with RAM — cache is faster and inside/close to the CPU; RAM is separate and slower.
AI-generated · claude-opus-4-7 · v3-ocr-computer-science