DEV Community

Discussion on: How Does Virtual Memory Work?

Collapse
 
visheshpatel profile image
Vishal Chovatiya

Yes you are right, when we load program, not whole program loaded initially. At first it only loads needed pages(program part).

If you see from compiler & os management perspective virtual memory management is very beneficial.
Bcoz when you compile binary statically, you will get all the addresses needed at compile time.
This is only possible due close design of ABI, compiler & os kernel.
Same goes for dynamic Compilation except absolute addresses(offsets will be generated)

Collapse
 
renegadecoder94 profile image
Jeremy Grifski

Just to bounce off Vishal here, I think virtual memory is also useful if you want to "virtualize" a system or process. For instance, you want to run a couple operating systems on the same hardware. Virtual memory would provide a nice layer between those systems and the hardware. In other words, you wouldn't need to statically allocate memory to the two systems. Instead, you'd give the illusion that both system would have access to all the memory through virtual memory.

Thread Thread
 
visheshpatel profile image
Vishal Chovatiya

Yes jeremy...!

Infact, modern days SoC has special hardware for virtual memory management & system virtualizer.
Recently i have worked on one in my office.