r/AskComputerScience • • May 14 '25
confused about virtual memory
If I got this right, the point of virtual memory is to ensure processes use unique physical address space.
Is this abstraction really needed ?
For example, say there are 2 C programs and each one does malloc. This asks the OS for memory. Why can't the OS guarantee that unique physical address space is given to the C program ?
2
Upvotes
View all comments
Show parent comment
2
u/purple_hamster66 May 17 '25
And the memory could also be physically housed, not on a chip, but across an interface (CPU/GPU shared memory, called unified memory), or on a disk (called swap space; or memory-mapped disks), or across a network (for cluster computing). Of course latency would be extreme, but this abstraction means that a computer could trade off speed in a random-access device for as-large-as-needed virtual memory, and the differences between memory spaces and I/O spaces blurs.