FutureLogic Blog β†’ Hardware β†’ IGCSE 0478

What is virtual memory?

Virtual memory is a memory-management technique that uses part of secondary storage to hold data and instructions when there is not enough available RAM. It allows programs to continue running, but accessing secondary storage is slower than accessing RAM.

Discover what happens when RAM fills up, how data is moved between RAM and secondary storage, and why excessive swapping can reduce performance in Cambridge IGCSE Computer Science (0478).

What is virtual memory?

RAM (Random Access Memory) holds the data and instructions currently needed by running programs. However, RAM has a limited capacity. If the computer needs to keep more information available than can fit in physical RAM, the operating system can use part of a secondary storage device as virtual memory.

Virtual memory uses secondary storage to extend the memory available to running programs β€” but it is not as fast as physical RAM.

Cambridge syllabus focus

Topic 3.8: understand the purpose of virtual memory, why it is needed and how using secondary storage instead of RAM affects computer performance.

Why does a computer need virtual memory?

Imagine a student has a web browser, a presentation, an image editor and several documents open. Each program needs memory. If the working data cannot all fit into physical RAM, the operating system can move less-needed pages of memory to a reserved area on an SSD or HDD, freeing RAM for other data.

RAM ALMOST FULLProgram AProgram BData→SECONDARY STORAGEVirtual-memory areaRAM: fast, limited capacityStorage: slower, more spaceIllustrative model — not a scale drawing
Diagram 1: RAM has limited capacity; a secondary-storage area can hold additional pages.

Check your understanding 1

Is virtual memory the same thing as installing more RAM?

Reveal answer

No. Virtual memory uses secondary storage and is slower than physical RAM. Adding RAM increases the amount of fast physical memory available.

How does virtual memory work?

Modern operating systems commonly manage memory in fixed-size blocks called pages. When a page that a program needs is not in RAM, a page fault occurs and the operating system retrieves it from secondary storage. If RAM has no suitable free space, another page may be moved out first.

  1. A program tries to access information.
  2. The required page is not currently in RAM.
  3. The operating system locates that page in secondary storage.
  4. Space is made in RAM if needed, possibly by moving another page out.
  5. The required page is loaded into RAM, and execution continues.
WHEN A PROGRAM NEEDS A PAGE1. ProgramRequests a page→2. StorageHolds needed page→3. RAMReceives the pageIf necessary, another page is moved out to make room.The program resumes once the required page is available.
Diagram 2: A simplified example of bringing a required memory page into RAM.
Exam tip: State that the operating system manages the movement of data between RAM and secondary storage. Avoid claiming the CPU simply uses an HDD exactly as if it were RAM.

Worked example β€” too many applications open

A laptop has 8 GB of physical RAM. Its running applications and operating system need more memory than can comfortably remain in RAM. The operating system may move less-active memory pages to its virtual-memory area. When the user returns to an application, the required pages may need to be loaded back into RAM.

Result: the applications may remain usable, but switching between them can become noticeably slower because secondary storage takes longer to access.

Check your understanding 2

Why might returning to a background application take longer?

Reveal answer

Some of its pages may have been moved to secondary storage. They must be loaded back into RAM before the program can use them.

Why does virtual memory affect performance?

RAM is designed for fast access. Even an SSD is much slower for memory access than RAM, and an HDD is generally slower still. Repeatedly moving pages between RAM and storage creates extra work and delays. When a computer spends too much time moving pages rather than running programs, this is called thrashing.

WHY TOO MUCH VIRTUAL MEMORY SLOWS THINGS DOWNRAM accessFasterStorage accessSlowerConceptual comparison only β€” bar lengths are not measured timings.
Diagram 3: RAM is faster to access than secondary storage; the bars are illustrative.
FeaturePhysical RAMVirtual-memory storage area
LocationRAM modulesPart of SSD or HDD
SpeedVery fastSlower than RAM
PurposeHolds actively used data and instructionsHolds pages not currently resident in RAM
Effect on performanceSupports rapid accessFrequent transfers can cause delays

Does virtual memory make a computer faster?

Not inherently. Virtual memory can let programs continue running when physical RAM is insufficient, but it cannot provide the same access speed as RAM. Increasing physical RAM may reduce the need for swapping, depending on the workload.

Common Cambridge exam mistakes

βœ— β€œVirtual memory is extra RAM inside the CPU.”

It uses an area of secondary storage, managed by the operating system.

βœ— β€œVirtual memory makes the computer faster.”

It helps manage memory shortages, but frequent transfers to storage can slow performance.

βœ— β€œEvery program is copied to the HDD.”

Only selected pages may be moved, and the backing storage can be an SSD or HDD.

βœ— β€œVirtual memory permanently increases installed RAM.”

The amount of physical RAM remains unchanged.

Original FutureLogic exam-style practice

These are original teaching questions, not official Cambridge examination questions. Suggested marks are indicative.

Question 1 β€” 2 marks

Define virtual memory.

Reveal model answer

Virtual memory uses an area of secondary storage (1) to hold data or instructions when insufficient physical RAM is available (1).

Question 2 β€” 3 marks

Explain why a computer may use virtual memory when several applications are open.

Reveal model answer

The applications require more memory than the available RAM can hold (1). The operating system moves less-needed pages to secondary storage (1), freeing space in RAM for currently needed data (1).

Question 3 β€” 3 marks

Explain why using virtual memory can reduce computer performance.

Reveal model answer

Secondary storage is slower to access than RAM (1). Pages must be transferred between storage and RAM (1), which introduces delays when the processor needs that data (1).

Question 4 β€” 2 marks

A student says, β€œVirtual memory is the same as adding more RAM.” Explain why this is incorrect.

Reveal model answer

Virtual memory uses secondary storage rather than installing additional physical RAM (1). Secondary storage is slower than RAM (1).

Quick quiz

  1. What does RAM stand for?
  2. When might virtual memory be needed?
  3. Where is virtual memory stored?
  4. What manages the movement of pages?
  5. Why can frequent paging cause delays?
  6. Does virtual memory increase installed RAM?

Quiz answers

Reveal all answers
  1. Random Access Memory.
  2. When available physical RAM is insufficient.
  3. In an area of secondary storage, such as an SSD or HDD.
  4. The operating system.
  5. Storage is slower than RAM, and transfers take time.
  6. No.

Final summary

RAM

Fast, limited physical memory.

Virtual memory

Uses secondary storage to hold pages.

Operating system

Manages page movement.

Performance

Frequent transfers can cause delays.

Virtual memory helps when RAM is insufficient β€” but secondary storage is slower than RAM.

Ready to master virtual memory?

Review why virtual memory is needed, how pages move between RAM and secondary storage, and why performance can decrease.