Home »
Operating System
Difference Between Virtual Memory and Cache Memory
Virtual Memory Vs. Cache Memory: In this tutorial, we will learn about the virtual memory and cache memory, difference between them.
By Monika Jha Last updated : May 07, 2023
What is Cache Memory?
In memory hierarchy, there is an additional level of memory which is Cache. It is high-speed storage and much faster than the main storage. It is much expensive as compared to main storage. So, a relatively small amount of cache is used.
Programs and data need to be in main storage to be executed. Program or data not needed immediately may be kept on secondary storage until needed and then brought into main memory for reference.
Cache storage imposes this level of shuttling on the system. Programs in the main memory shuttled to the cache before being executed. In the cache, they may be executed much faster than in the main storage.
There is a cache hit when the cache has a copy of the required data and there is a cache miss if the cache does not have a copy of that data item.
The overhead involved in shuttling programs back and forth will be reduced so the performance increase obtained by the faster execution possible in the cache.
Cache memory is a faster memory type that acts as a buffer between main memory and the processor.
What is Virtual Memory?
It is a memory management scheme that permits the execution of various processes which may not be entirely in RAM. It is possible that user programs can be larger than physical memory.
A 'swap file' is created in this area which is used to sustain data which the processor does not need in a frequent amount of time.
It makes the programming much simpler because the programmer doesn't have to take care of the size of the physical memory available.
By this CPU utilization and throughput increases as the user utilizes less physical memory. So more users can keep their programs in memory.
Difference between virtual memory and cache memory
The following are the difference between virtual memory and cache memory:
S.No. |
Virtual Memory |
Cache Memory |
1 |
The term "virtual memory" refers to space allocated on a hard disk where data can be stored for fast access. |
Cache memory is a small high-speed memory usually Static RAM (SRAM) that contains the most recently accessed pieces of main memory. |
2 |
Virtual memory enlarges the volume of RAM. |
By using cache Access time consumed by the processor is less as compared to main memory. |
3 |
Operating system has the control over virtual memory. |
Hardware has the control over cache memory. |
4 |
The size of virtual memory is more than cache memory. |
The size of Cache memory is less than virtual memory. |
5 |
In virtual memory, larger programs can be executed while there is a sufficiently small amount of main memory. |
The cache contains data items that are most frequently used by the processor while the whole program resides in the secondary memory. |