Memory, in general, is the term used for the storage of data in any computer system or digitally operating device.Volatile files are the dynamic files being changed after every operation (software files, system files) being stored in a Random Access Memory (RAM), and Non-Volatile files are stored in a Read-only Memory (ROM). But another theory named Virtual Memory that virtually combines the two of them.
Since the word Memory had been coined, we have established two of the most powerful of them being used in almost every smart-appliances operating digitally for storing Volatile and Non-Volatile files in a system.
These physical memories are often hard to replace or upgrade when in need and can cost few bucks for the same. However, the research and development of tech are coming up with new tricks for the functions that weren’t possible even a few years ago in the name of Virtual Memory.
Virtual Memory: Overview
A comparatively newer memory-management algorithm used for upscaling the random-access limit of memory virtually. In spite of the fact that the first Virtual Memory computer was introduced in the late 1960s as a solution for increasing memory prices. However, the mass adoption took long and started recently in the smartphone market.
Virtual Memory uses the inactive space in the secondary memory or storage device in association with current RAM. This creates space for a big application or many programs to run at once by swapping data between primary and secondary storage devices.
The inactive data in RAM is replaced by a secondary storage device with more actively needed data for access. This creates or increases the random access limit of any memory.
Need for Virtual Memory
As discussed earlier, the concept of Virtual Memory was developed in the times when physical storage devices were costly and are still costly in terms of RAM per Gigabytes than usual HDDs or SSDs. Equipping Virtual Memory can increase RAM of any system of system virtual at no cost. A combination of unused space in read-only memory and physical RAM might be a better option than opting for a physical one.
Another context can be explained as various computers have a defined or compatible RAM limit for an architecture. In the above context, Virtual Memory can play a vital role in upgrading the system without spending on the complete computer parts to increase RAM compatibility.
Physical Memory vs Virtual Memory
Virtual Memory is a logical or memory-management algorithm, physical memory, on the other hand, is physical memory. Other core differences listed below in the tabled form.
|Criteria||Physical Memory||Virtual Memory|
|Type||Actual Memory||Logical Memory|
|Flexibility||Not much flexible||Much Flexible|
|Max. Size||RAM||HDD/ SSD|
|Upgradability||Can’t much upgraded easily||Easily Upgradable upon one click|
How Virtual Memory Works?
In computing, implementing software and hardware, the operating system maps the virtual address (memory address used by any software to run) into a physical address in memory. The Virtual address is later converted to a physical address in the Memory-Management Unit (often referred to as MMU) in a CPU.
In other words, Program threads and other necessary data are stored at a virtual address, being in a RAM, when space is urgently requested by any other program, the corresponding space is replaced with the data and stored in a Virtual Memory. The time between the respective data replacement time is negligible but for a system with onboard low RAM can result in the consumption of a lot of resources of CPU and subsequently reduce output performance.
The above cause sometimes results in a huge performance hit and can slow down the entire system. However, the performance hit can easily be minimized, if secondary storage used can be faster enough to handle the situation.
Types of Virtual Memory
Virtual Memory is basically managed with two approaches i.e. of two types, namely Paging and Segmentation.
Pages (In Computing) is defined as the number of divisions or blocks (of 4k size), upon which processes run. Since Processes are allotted just enough page to fulfill memory requirements but however leave unused spaces or wasted, every time being used. With every operation, Pages (blocks or divisions in memory of size 4k) are replaced between RAM and Page files that represent Virtual Memory.
Besides Paging, Segmentation is an alternative strategy of memory management. This is a much effective way rather than Paging that involves processes with a fixed size of pages, Segmentation involves processes with segments with variable sizes according to needs to fulfill the requisite memory requirements. Unlike the Paging system, where much memory was wasted due to fixed sizing, Segmentation allowed programs to decide the allocations logically without wasting any spacings.
However, every system poses its backlogs where Segmentation is none exceptional. Sometimes, small chunks of memory that if failed to utilize over time can lead to fragmentation and remain scattered and unused. If the same left unused for long can lead to performance hits, and inefficiency of the system with subsequent reduction inefficiency.
Implementation in OS
Implementation or execution of any prototype is considered to be the most difficult part of any new or upgrading feature in an Operating System. Virtual Memory has basically nine algorithms for its proper functioning.
The concept of Demand Paging encourages keeping all the pages in the secondary storage i.e. DASDs or Direct-access Storage devices until they are needed to execute a corresponding function. In other words, it may be said RAM or main memory only needs a part of the process, or pages to be present. Hence, it is said not to load pages of the frame until being needed by the CPU, with most of the pages being kept in a secondary storage device. Therefore if any page that’s never needed or demanded by the CPU is never loaded by the system.
Due to its nature of swapping pages only with its requirement as from CPU, Demand Paging is often referred to as Lazy Swapper.
Page Replacement Algorithm
There is two main feature of Virtual Memory i.e. Frame Allocation and Page Replacement Algorithm. In the above context, One of them deciding the number of frames that needs to be allocated for a particular process, and another being responsible for the replacement of faulty pages (when the requested page is not found in the main memory).
The algorithm functions with limited access to analyze the pages provided by the hardware and selecting the pages with faults and needed replacement. Thereby minimizing the total number of page misses and optimizing the processing time.
First In First Out (FIFO) Algorithm
The algorithm is considered as one of the simplest among other page replacement algorithms that maintain a queue for every page in the memory needed for the execution of any process. Among the queue, the oldest pages are kept in front which is considered as the best option for replacements when any page faults.
Optimal Page Replacement
This page replacement algorithm uses the page set to reject future requests or the pages determined not to be used for a long duration in the future by the Operating System. However, practically this algorithm is not valid for today’s life for lack of computing intelligence. Since this algorithm is the most ideal and used as a benchmark for the other algorithms to analyze the results.
Least Recently Used (LRU) Algorithm
A great approximation from the above Optimal Page algorithm, the page being used over time will always be useful but the page not used over years won’t be used in the future. Hence this theory suggests removing the page that isn’t used over time when any page faults. However, according to various tech experts, the theory is the best as it minimizes the loss of any usable pages.
However, LRU Algorithms are a bit costlier than the other page replacement algorithms as it comes bundled with other mini algorithms. The algorithm detects the past history of every page in-frame that subsequently eats up more resources than other systems. This in return causes forced system thrashing (for low-end systems).
Least Frequently Used (LFU) Algorithm
The algorithm is sometimes referred to as the synonym for Least Recently Used (LRU) page replacement algorithm. Since LRU Algorithm replaces pages that are not used for a long time or recently, the LFU algorithm involves replacing pages that aren’t used frequently.
Page Buffer Algorithm
Unlike other page replacement algorithms, Page buffer also works on a similar principle. The system maintains a list of pages in a pool, whenever any page fault occurs, the algorithm updates the table, and the pages are subsequently swapped out of the main disk. This in return
How to increase Virtual Memory Manually
Virtual memory is not fixed it can be manipulated. It’s not preset it can be set according to our use and need. Here are some steps to increase the Virtual memory for your system with various operating systems i.e. Linux, Windows, and iOS.
Windows is so far recognized as one of the best software and is a paradise for gaming. With time, it had proven its ability to handle various scenarios. Virtual Memory, the need to today’s world can be manually altered by the settings below:-
- Go to the start menu and hover over to setting
- Search for Performance
- Click on the adjust the appearance and performance of windows.
- In the next tab click the advance tab and then click on change under the virtual memory section.
- At the bottom of the tab, check the recommended value and how it compares to the currently allocated.
- If the current value is less than the recommended value then change accordingly or if you want to customize according to yourself click on a custom size.
- Click ok to save the new setting.
In our research upon increasing virtual memory, We didn’t found the option to do the same. However, some suggest it doing via jailbreaking the operating system and some suggest that the option is in the preferences tab.
Virtual Memory Thrashing
When the virtual memory in an operating system is misused or overused either due to bigger virtual memory over a comparatively smaller Random-Access Memory (or a RAM). This results in increased page faults during paging a memory.
Else in technical terms, it may be said that Virtual memory addressing is directly proportional to the degree of multiple programming. The degree of multiple programming means the number of programs executing in the process simultaneously. So if we increase the degree of multiple programming then each and everyone will have a lesser number of frames for their execution.
If I have five frames and increase the degree of multiple programming, that program will be allocated to four frames if we increase the degree of multiple programming further then it might be allocated for two frames then all the program during execution they will phase a page fault. The page fault occurrence probability will be drastically high. So the system will be busy not for the execution of the program but for paging, this situation is known as thrashing.
Advantages of Virtual Memory
Virtual memory is an old technology but wasn’t largely accepted by the tech industry. Hence without largely use cases, Virtual Memory has some advantages as mention below:-
Allow more Application to run simultaneously
Virtual memory increases space in RAM by transferring all the application data that aren’t used in current use, i.e minimized or running in the background. Most of the programmer use virtual memory as they have to compile and run a huge number of programs which required a lot of space. So virtual memory helps to run more and more programs easily and smoothly.
Can run larger apps that a physical RAM can’t handle alone
Sometimes we often only use one or two applications simultaneously but these applications take more space as it should and makes trouble to open larger applications. So we can transfer all the data of the opened application to the virtual memory to increase the RAM space to its lowest. This definitely helps to run bigger application files without any problem.
Provides a method to increase RAM without spending any penny
With the help of virtual memory, RAM space can easily increase without any cost. This is only the reason why people buy less storage RAM and even they knew that might not be sufficient for their work.
Increased Privacy (Memory Isolation)
Since the memory allotment and allocations are based on logic and Virtual Memory involves a better and enhanced algorithm for the same. Memory isolation involves complete restriction for a program to interfere with other programs’ slots or memory. This in return increases the core security of the system.
Disadvantages of Virtual Memory
Some of the disadvantages of Virtual Memory, are mention below.
Doesn’t offer same performance as physical RAM
It takes some time when the data of RAM transferred to a hard disk in form of virtual memory and again while transferred the data from virtual memory to RAM takes some moments. Sometimes this is the reason for the decrement smoothness in RAM as well as speed. So, for this reason, it doesn’t offer the same performance as physical RAM does.
Slower application switching
As in the above point, it is mentioned that switching data from RAM to virtual memory and again from virtual memory to RAM takes some moment that decreases the speed of the system. The same reason is responsible for slower application switching because it takes some moment to gain the data from virtual memory for its functionality.
Affect overall performance of the system
When there are lots of units in use at a time the RAM, hardware, and the software. The system had to perform a lot of tasks each time when the data is transferred to virtual memory to RAM or RAM to virtual memory. Overall all this simultaneously decreases the performance of the system.
Consume unnecessary spaces
There should be space for transferring and storing the data on a hard disk. If your hard disk isn’t spacy virtual memory cannot be a fruitful option for you.
In the end, We would like to conclude that However Virtual Memory is powerful and user-friendly technology but in spite of this fact, it slows the system down in various scenarios. Hence, handling it with the best settings is preferred to get the best of the same.