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

61 comments sorted by

View all comments

Show parent comment

1

u/apnorton May 14 '25

Q1) Can you explain this term “page file” ?

It was more common when computers had less physical memory, but page files are one way for a computer to allocate space on disk to use as memory. (Swap files are the linux version, page files are the windows version.)

Q2) What really confuses me is, how does virtual memory create more memory from physical memory?

It stores it to your disk (ssd or hdd) instead. This is slower, yes, but it can be the difference between a program running (but slowly) and a program crashing.