Explain Virtual Memory in Operating System?

  • Virtual Memory is a storage mechanism that offers users the illusion of having a very big main memory.
  • Virtual memory is needed whenever your computer doesn’t have space in the physical memory
  • A demand paging mechanism is very much similar to a paging system with swapping where processes are stored in the secondary memory and pages are loaded only on demand, not in advance.
  • Important Page replacement methods are 1) FIFO 2) Optimal Algorithm 3) LRU Page Replacement.
  • In FIFO (First-in-first-out) method, memory selects the page for a replacement that has been in the virtual address of the memory for the longest time.
  • The optimal page replacement method selects that page for a replacement for which the time to the next reference is the longest.
  • LRU method helps OS to find page usage over a short period of time.
  • Virtual memory helps to gain speed when only a particular segment of the program is required for the execution of the program.
  • Applications may run slower if the system is using virtual memory.