CS  ·  Computer Systems

Memory

Lesson CS6 of 10 Approx 60 min RAM, ROM, cache and virtual memory
Learning intentions
  • Understand why main memory is needed while a computer is running
  • Compare RAM, ROM and cache using their purpose and characteristics
  • Explain volatility, capacity and the use of virtual memory
Success criteria
  • I can state that RAM stores programs and data currently in use
  • I can describe ROM as non-volatile memory that stores start-up instructions
  • I can explain why cache improves processor performance
  • I can describe virtual memory as part of backing storage used as if it were RAM
Warm up — what do you already know?

Answer before the lesson begins. These check prior knowledge — it's fine if you're unsure.

1. What does the processor do with instructions stored in memory?

2. Which statement best describes backing storage?

3. What does volatile mean when describing memory?

Key vocabulary

Main memory
Memory directly accessed by the processor while programs are running.
RAM
Random Access Memory; read/write, volatile memory for programs and data currently in use.
ROM
Read Only Memory; non-volatile memory that stores start-up instructions.
Cache
Very fast memory close to or inside the processor, used for frequently accessed instructions and data.
Volatile
Loses contents when power is switched off.
Non-volatile
Keeps contents when power is switched off.
Virtual memory
Part of backing storage used as if it were RAM when main memory is full.
Capacity
The amount of data a memory or storage device can hold, usually measured in bytes.

Memory

Why memory is needed

A computer cannot process a program directly from long-term storage all the time. Storage devices such as SSDs and hard disk drives are useful because they keep files when the power is off, but they are much slower than the processor. When a program is opened, the operating system loads the program instructions and the data being used into main memory. The processor can then fetch instructions and data quickly enough to keep the computer responsive.

Main memory sits between the processor and backing storage in the memory hierarchy. The closer memory is to the processor, the faster it tends to be, but it is also usually smaller and more expensive per byte. This is why a computer might have a large SSD, a smaller amount of RAM, and a very small amount of cache.

RAM

RAM stands for Random Access Memory. It stores the operating system, currently running programs and the data those programs are using. For example, when a pupil opens a web browser, the browser program and active web pages are loaded into RAM. When they edit an image, the image data being changed is also held in RAM.

RAM is read/write, meaning the processor can read data from it and write new data to it. RAM is also volatile. If the power is switched off, the contents of RAM are lost. This is why unsaved work can disappear after a crash. Saving a file writes it from RAM to non-volatile backing storage.

ROM

ROM stands for Read Only Memory. It stores instructions that are needed when the computer starts up, such as firmware or boot instructions. ROM is non-volatile, so it keeps its contents when the computer is switched off. This matters because the computer needs start-up instructions before the operating system has been loaded from storage.

At National 5, describe ROM as memory that is normally read from rather than written to by the user. It is not used for open documents or current program data. A common exam contrast is: RAM is volatile and holds programs/data currently in use; ROM is non-volatile and holds start-up instructions.

Backing storage: largest, slowest, non-volatile RAM: programs and data currently in use Cache: very fast, very small Processor faster access larger capacity
Memory close to the processor is fast but small. Backing storage has much larger capacity but is slower.

Cache memory

Cache is very fast memory close to, or built into, the processor. It stores instructions and data that the processor is likely to need again soon. Accessing cache is faster than accessing RAM, so using cache can improve performance because the processor spends less time waiting for data.

Cache has a much smaller capacity than RAM. It is not where user files are saved, and pupils do not choose what to put in cache. The computer system manages it automatically. In an exam, a strong answer links cache to performance: frequently used data can be accessed more quickly than if it had to be fetched from RAM each time.

Virtual memory

If RAM becomes full, the operating system may use virtual memory. Virtual memory uses part of backing storage as if it were RAM. This can allow more programs to remain open, but it is slower than real RAM because backing storage is slower than main memory.

Virtual memory is useful, but it is not a perfect replacement for RAM. If a computer relies heavily on virtual memory, it may slow down because data has to be moved between RAM and backing storage. This is why adding more RAM can improve performance when a computer often runs out of memory.

Memory typeVolatile?Main purposeTypical exam phrase
RAMYesPrograms and data currently in useread/write; contents lost when power is off
ROMNoStart-up instructions/firmwarenon-volatile; read-only in normal use
CacheUsually yesFrequently used data and instructionsvery fast; improves processor performance
Virtual memoryUses storageExtra space when RAM is fullslower than RAM; uses backing storage

Worked examples

Example 1 — Choosing RAM or ROM

A question asks which memory stores the instructions needed when a computer is first switched on.

1
Look for the clue: the instructions must still exist before the computer has loaded the operating system.
2
That means the memory must be non-volatile.
3
The answer is ROM, because it stores start-up instructions and keeps them when power is off.
Example 2 — Explaining cache

A computer repeatedly uses the same instructions while running a game. Explain how cache can improve performance.

1
The repeated instructions can be stored in cache.
2
Cache is faster to access than RAM.
3
The processor can fetch those instructions more quickly, reducing waiting time and improving performance.
Example 3 — Virtual memory slowdown

A laptop becomes slow after many applications are opened at once. Explain why virtual memory might be involved.

1
Opening many applications can fill RAM with current programs and data.
2
The operating system may use virtual memory, which is part of backing storage used as if it were RAM.
3
Backing storage is slower than RAM, so moving data to and from virtual memory can make the laptop slower.
Now you try

A pupil opens a browser, a word processor and an image editor. The computer starts to slow down and the operating system begins using virtual memory.

Answer the following:

  1. Which memory stores the open programs and current data?
  2. Why does virtual memory allow the computer to keep working?
  3. Why can using virtual memory make the computer slower?
  1. RAM stores the programs and data currently in use.
  2. Virtual memory uses part of backing storage as if it were RAM when RAM is full.
  3. Backing storage is slower than RAM, so fetching data from virtual memory takes longer.
Common mistakes
Calling RAM permanent storage. RAM is temporary and volatile. Files must be saved to backing storage if they need to be kept.
Saying ROM stores all programs. ROM stores start-up instructions. Open applications and current data are held in RAM.
Treating cache as extra file storage. Cache is very fast memory for frequently used instructions and data; users do not save documents there.
Forgetting that virtual memory is slower. Virtual memory can help when RAM is full, but it uses backing storage, so performance can drop.
Exam tip

When comparing memory types, use paired facts. For example: RAM is volatile and stores programs/data currently in use; ROM is non-volatile and stores start-up instructions. For cache questions, do not just write "it is faster". Link the speed to the processor accessing frequently used instructions or data more quickly.

Task Set

Questions 1-5 are auto-checked. Questions 6-9 are self-marked — write your answer, then reveal the model answer to check your work.

1. Which memory stores programs and data currently in use? TYPE 1

2. Which statement about ROM is correct? TYPE 1

3. Why can cache improve performance? TYPE 1

4. What is virtual memory? TYPE 1

5. Which option lists memory from fastest/smallest to slowest/largest in the usual hierarchy? TYPE 1

6. Describe two differences between RAM and ROM. TYPE 2

RAM is volatile, so its contents are lost when power is switched off, while ROM is non-volatile and keeps its contents. RAM stores programs and data currently in use and can be read from and written to. ROM stores start-up instructions and is normally read from rather than changed by the user.

7. Explain how cache memory can improve processor performance. TYPE 2

Cache stores frequently used instructions and data in very fast memory close to the processor. The processor can access cache faster than RAM, so it spends less time waiting for repeated data or instructions to be fetched. This can improve performance.

8. A computer has many applications open and RAM becomes full. Explain what virtual memory does and why the computer may slow down. TYPE 3

Virtual memory uses part of backing storage as if it were RAM when RAM is full. This allows the computer to keep working with more programs or data than can fit in RAM at once. It may slow down because backing storage is slower than RAM, so transferring data between RAM and virtual memory takes longer.

9. A pupil loses unsaved work when a desktop computer loses power, but the computer can still start up again. Use RAM and ROM to explain both parts of this situation. TYPE 3

The unsaved work was held in RAM. RAM is volatile, so its contents are lost when power is switched off. The computer can still start up because ROM is non-volatile and keeps the start-up instructions needed when the computer is switched on again.
Teacher notes — Shift+T to hide

Suggested timing: 60 minutes. Warm up 6 min; vocabulary 6 min; notes and diagram 20 min; worked examples 10 min; now you try 5 min; task set 13 min.

Key misconception to address: Pupils often say RAM is storage because it stores data. Keep separating temporary memory from long-term backing storage.

Live demo suggestion: Open several browser tabs or applications and show memory usage in Activity Monitor/Task Manager if available. Link the behaviour to RAM pressure and virtual memory.

Extension question: Why does more RAM not always make a computer faster? Steer towards bottlenecks: if RAM is not full, CPU, storage or network may be the limiting factor.

SQA command words covered: "state", "describe", "compare", "explain".