VM is indeed an important concept, but it is not the reason why you are able to watch an 8GB movie or play an 8GB game on a computer with 4GB RAM. Those things are just not loaded into memory completely. And given the slow speed of hard disks before SSD you did not want the computer to start swapping, because it slowed down everything, sometimes to a point where the computer was unusable.
A very interesting question however is: Why do we still have the concept of virtual memory today, now that RAM is so cheap?
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)
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.
VM is indeed an important concept, but it is not the reason why you are able to watch an 8GB movie or play an 8GB game on a computer with 4GB RAM. Those things are just not loaded into memory completely. And given the slow speed of hard disks before SSD you did not want the computer to start swapping, because it slowed down everything, sometimes to a point where the computer was unusable.
A very interesting question however is: Why do we still have the concept of virtual memory today, now that RAM is so cheap?
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)
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.
Yes jeremy...!
Infact, modern days SoC has special hardware for virtual memory management & system virtualizer.
Recently i have worked on one in my office.