Virtual memory gives each process a private address space, a range of addresses the OS maps onto physical RAM. Your program sees one continuous range starting near zero, even though physical memory is shared and scattered.
The hardware and OS translate every virtual address to a physical one during access. A process can only reach memory it owns, because its map has no entry for anyone else's pages.
That isolation is the main reason for separate address spaces. One process cannot read or corrupt another's data through a stray pointer. It also simplifies your code, since every program can assume the same layout. And because pages not in use can wait on disk, the machine can run programs whose combined footprint exceeds its RAM.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Two processes load the same shared library. Does RAM hold two copies of its code?No. Both map the same read-only physical pages into their own address spaces. Writable pages stay private through copy-on-write.
Virtual memory gives each process its own private range of addresses, and the OS maps that range onto physical RAM.
The program sees one continuous range starting near zero, even though the physical memory under it is shared and scattered.
On every access, the hardware and the OS translate the virtual address into a physical one.
The main reason for separate address spaces is isolation. A process's map has no entry for anyone else's pages, so a stray pointer can't read or corrupt them.
It also makes code simpler, because every program can assume the same layout.
Pages not in use can wait on disk, so programs bigger than RAM combined still run, but if they keep needing those pages back, the disk becomes the bottleneck.
Weak answers to avoid
Says virtual memory just means swap spacePaging to disk is one benefit, not the definition. Lead with per-process address spaces and translation, then mention that idle pages can wait on disk.
Lists features but never says why it isolatesThe question asks why each process gets its own space. Say it first. A process's map has no entry for other processes' pages, so stray writes can't reach them.
Thinks the kernel translates every addressThe MMU does each lookup in hardware, using page tables the OS built. The kernel runs only on a fault. Get this wrong and the TLB follow-up goes badly.
Assumes virtual addresses are unique system-wideTwo processes can use the same virtual address for different physical pages. That overlap is the point, since each gets the same layout, mapped separately.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.