It is very important to understand the concept of memory management although Memory management is the very typical topic. A 32-bit (MIPS) processor promise to their each program to provide the 32-bit address space means that every program has the right to access any bytes between the address of 0 to (2^32 -1).
Note: 32-bit address space means, you have right to access the 4 GB of memory.
In initial era of computer processor directly access the physical memory of the system to perform the read and write operation.
The main problems arise when the system does not have the adequate amount of physical memory (RAM). In that situation, if the program tries to get access the address which does not exist in the physical address space then the system could be a crash.
So initially the concept of virtual memory come to avoid the lesser memory issues but nowadays it play the vital role and solve many other problems.The virtual memory is the part of memory management techniques and it creates an illusion that the system has a sufficient amount memory.In the another word you can say that virtual memory is a layer of indirection.
In initial era of computer, computer rarely has 4GB RAM but it is the common today for the new generation PC. So initially the concept of virtual memory come to solve the lesser memory issues in the system but nowadays virtual memory not only solve the lesser memory issues but it also solve some other issues which usually come into a PC when there is more than one application running at a time.
In this article, I am describing some issues which make your PC slow and also describe the advantage of virtual memory.
Some Issues related to memory
Lesser memory issues:
It’s the most dangerous issues which generally occur when your system have a little amount of RAM,I have already described this issue in the beginning of the article.We can solve this issues using the concept of virtual memory, it create an illusion of there is a lot of memory available in the system using the technique of indirection.
Without the virtual memory program address directly map with the RAM addresses means that there is one to one relation exist between the program and ram memory addresses.To make more clear this scenario supposes there is any program address like 0x05 and this address directly map with the RAM address 0x05 but anyhow if this location not available in RAM then your system will be the crash.
We can solve this problem by using the virtual memory,it prevents from the one-one mapping between the program and RAM address and it creates a layer between the RAM and program address which is used to map the program address and RAM address and prevent the system being crash.
Image to show how to virtual memory handles the lesser memory scenario
Suppose there is two programs running simultaneously.The first program required 512 MB and second program required 1 GB of physical memory for the execution.
When the first program is terminated by the user then memory which occupied by the first program will be release and now we have the total 1GB amount of free space to execute the other program,but there is one drawback,free memory is not continuous.
So if the user runs a third program which has required only 1 GB of physical memory still unable to execute because its want a continuous 1GB free memory even though we have 1 GB of memory space that’s the cause of memory fragmentation.
We can solve this problem using the virtual memory because, with virtual memory, we do not directly access the physical memory MMU play a vital role and map the program address space to the physical address space.Each program has own mapping and using the mapping we can put our program data wherever we want in the RAM.
Keep Program secure
We know that each program can access any 32bit memory of address.So the problem occurs when two programs share the same address (like 512) of address space to store their result.
In that situation result of one program can be altered by another program and we will not get our desired result.It’s the biggest issues which can be solved by the virtual memory.
I have already described, with virtual memory program address map with RAM address.Here program 1 and 2 have the own program address space so they can not access each other data and their program address space map with different RAM address.
Your opinion matters
Although here, I have tried to discuss a few advantage of virtual memory but I would like to know your opinion on the advantage of virtual memory. So please don’t forget to write a comment in the comment box.