Difference Between Physical and Virtual Memory
Physical memory and virtual memory are two forms of memory used to store data in a computer. Physical memory refers to chips such as RAM (Random Access Memory) memory and storage devices like hard disks that are used to store data. Virtual memory is a memory space created by the OS when the computer does not have enough physical memory to run a program. Virtual memory is created by combining the RAM with hard disk space. Virtual memory allows large programs to run faster when the RAM is not enough.
The physical RAM and hard drives in the computer that are used to store data comprise physical memory of a system. In a computer, operating system, application software and data currently used are stored in RAM, so they can be quickly accessed by the CPU. The RAM can be accessed faster than other storage devices like hard disk and CD-ROM. However, data exist in RAM only when the computer is switched on and working. When the power is off, entire data in RAM is gone and the operating system and other data is loaded back to RAM from hard drive when the computer is on. The hard drive is a non-volatile memory (memory that retains data even when it is powered off) that is used to store data in a computer. It is composed of flat circular disks known as platters which save magnetic data. Data is written and read from and to these platters.
Virtual memory is used when the computer lacks RAM space to run a program. Virtual memory is RAM space combined with the hard disk space. When the computer does not have enough RAM space to run a program, the data is transferred from RAM to a paging file by virtual memory, freeing up space in RAM. A portion of hard drive is used to keep the page file. This process of transferring is done so quickly that the user does not feel any difference. Virtual memory can hold an entire block of data while the part which is getting executed remains on the RAM. So the virtual memory allows the operating system to run several programs simultaneously and the increase in the degree of multiprogramming. Virtual memory increases the size of programs that could be executed and provides cost efficiency because hard disk memory is cheaper than RAM.
What is the difference between Physical and Virtual Memory
The physical memory refers to the physical devices that stores data in a computer such as RAM and hard disk drives while virtual memory is the space of RAM combined with the hard disk space to store data in RAM when space is not enough in RAM. The part of the hard drive is used to keep records of the pages that are used by virtual memory to store data that is transferred from the RAM. Although the act of exchanging data between page files on the hard drive and RAM is quite fast (using virtual memory), but lot of swapping can slow down the performance of your system on a whole.