-1

Let's suppose that I have a computer with unlimited RAM(Theoretical idea) to accommodate all the processes that are ready to be executed. Then do I still need the virtual memory ?. And if yes what can be the possible change in performance if my computer doesn't have a virtual memory?

Tauro
  • 59
  • 7

2 Answers2

2

Virtual memory is used for 3 purposes:

  • to bypass barriers - e.g. the limited amount of physical RAM installed

  • to improve performance - e.g. "memory mapped files" (pretending data was loaded from a file into memory, even though it wasn't and the expensive disk IO was postponed until its actually needed)

  • to enforce isolation/protection - e.g. so that something in one virtual address space can not normally (without special arrangements - "shared memory") access something in a different virtual address space.

And if yes what can be the possible change in performance if my computer doesn't have a virtual memory?

The first thing that'd happen is that all of the software will crash due to not having any isolation. Specifically; every process will expect to use addresses starting at (e.g.) 0x0040000 and will trash each other's code (because 2 or more processes can't uses the same addresses at the same time for different things unless they're using different virtual address spaces). In theory; this problem can be fixed (e.g. by using relocatable code) so that it "works" (doesn't crash but becomes a huge security disaster); but any attempt to do that has its own performance cost.

The main problem for performance (ignoring stability, security, etc) is that any RAM that is not used by processes (or the OS itself - kernel, etc) is RAM that the OS can use to cache things like file and directory data (and DNS entries, and ...). Tricks to avoid/reduce the use of physical RAM ("allocated on write", "copy on write", memory mapped files) are tricks that increase the amount of RAM that can be used for (file, directory, DNS, ..) caches and increase performance. In theory; if you have several TiB of RAM (enough to cache all files in RAM, in addition to all processes and the OS itself) then most of the performance benefits of virtual memory disappear (but only if the caches are "warm" and not empty - e.g. if you never reboot the computer).

Brendan
  • 35,656
  • 2
  • 39
  • 66
1

The concept of virtual memory came into existence on the idea that if primary memory is insufficient, then secondary memory can be used considering it as primary.

But, in your scenario, if you have sufficient RAM or main memory (in ideal case), then you do not need virtual memory.

Deepak Tatyaji Ahire
  • 4,883
  • 2
  • 13
  • 35