In the most of the computer system, the physical main memory is not as large as address space of the processor.
Suppose user tries to run a program.
If the program run by the user does not completely fit into the main memory then the parts of its currently being executed are stored in main memory and remaining portion is stored in secondary storage device such as HDD.
When a new part of program is to be brought into main memory for execution and if the memory is full, it must replace another part which is already is in main memory.
As this secondary memory is not actually part of system memory, so for CPU, secondary memory is considered as Virtual Memory.
Virtual memory is a memory management technique that is implemented using both hardware and software.
It maps memory addresses used by a program, called virtual addresses, into physical addresses in computer memory.
Benefits of having Virtual Memory:
Large programs can be written, as virtual space available is huge compared to physical memory.
Less I/O required, leads to faster and easy swapping of processes.
More physical memory available, as programs are stored on virtual memory, so they occupy very less space on actual physical memory.
Disadvantages of Virtual Memory:
Applications run slower if the system is using virtual memory.
It takes more time to switch between applications.
Less hard drive space for your use.
It reduces system stability.