Virtual memory is an operating system feature that enables the computer to compensate for the lack of physical memory by transferring data from random access memory to disk storage.
This process is temporary and is designed to work with a combination of RAM and hard disk space.
This means that when RAM is depleted, virtual memory can move data from RAM to a space called a paging file. This process frees up RAM space and the computer completes its task.
Sometimes a message may be displayed to the user saying that virtual memory is not enough, which means that either more RAM space needs to be added or the paging file size needs to be increased.
What is virtual memory? In other words
Virtual memory is a memory management technique based on which secondary memory can be used as part of the main memory. Virtual memory is a common method used in computer operating systems (OS).
Virtual memory uses both hardware and software to enable the computer to compensate for the lack of physical memory and to temporarily transfer data from random access memory (RAM) to disk storage. Transferring memory packets to hard disk files enables the computer to treat secondary memory like main memory.
Today, most personal computers (PCs) come with at least 8 GB (GB) of RAM. But, sometimes, this space is not enough to run several programs simultaneously. This is where virtual memory comes into play. Virtual memory transfers recently unused data to a storage device, such as a hard drive or solid-state drive (SSD), so that RAM space can be freed up.
Virtual memory to improve system performance, multitasking, and use very large applications; is important. However, users should not rely too much on cyberspace, as this memory works significantly slower than RAM. If the operating system is forced to exchange data in most cases between virtual memory and RAM, the computer will slow down - this is called a crash.
Virtual memory was introduced and used when physical memory - known as RAM - was expensive. The amount of RAM in computers is limited, so if several programs want to run simultaneously, the RAM space will be short. The system uses virtual memory to use part of the hard drive to simulate RAM. Using virtual memory, a system can run larger programs or multiple programs simultaneously; And without the need to buy more RAM, it looks like it really has more storage space.
How does virtual memory work?
Virtual memory uses both hardware and software to function. When an application is executed, the application's data is stored in a physical address using RAM. A memory management unit (MMU) transmits the address to RAM and automatically translates the addresses. The MMU can, for example, map a logical address space to a corresponding physical address. If anywhere, RAM space is urgently needed for a subject, data can be transferred from RAM to virtual memory.
The computer memory management unit actually tracks and tracks these transfers between virtual and physical memory. If the data is needed again, the computer MMU uses the context switch to resume execution.
When copying virtual memory into physical memory, the OS divides the memory by the number of addresses or page files or swap files, which is a fixed value. Each page is stored on a disk, and when needed, the operating system copies it from the disk to the main memory and translates the virtual addresses into real addresses.
However, the process of exchanging virtual memory with physical memory is relatively slow. This means that virtual memory usually reduces performance significantly. Because of the exchange of information, it is often assumed that computers with more RAM perform better.
Types of virtual memory
Computer MMU can manage virtual memory functions. On most computers, the MMU hardware is integrated with the CPU. The CPU also creates virtual address space. In general, virtual memory is either paginated or segmented.
Paging divides memory into several sections or paging files. When a computer uses the available RAM, pages that are not in use; Transferred to a hard drive using an exchange file. Is a space swap file on the hard drive that should be used as a virtual memory extension for computer RAM. When a swap file is required, it is sent back to RAM using a process called page swapping. This system ensures that the computer operating system and applications do not run outside of real memory. The maximum page file size can be up to 4 times the physical memory of a computer.
The virtual memory pagination process uses page tables, which translate the virtual addresses used by the operating system and applications into the physical addresses used by the MMU. Inputs to the page table indicate whether the page exists in Rome. If an operating system or application does not find what it needs in Rome; The MMU then responds with a page error to the lost reference memory to force the operating system to return the page to memory when needed. When a page exists in Rome, its virtual address appears on the table page.
Segmentation is also used to manage virtual memory. This approach divides virtual memory into sections of different lengths. Unused partitions in memory can be moved to virtual memory space or hard drive.
Processes or segmented information are tracked in a segment table that indicates whether a segment exists in memory, whether it has been modified, and what its physical address is. In addition, file systems in segmentation consist only of segments that are mapped to the potential address space.
Segmentation and pagination differ in how memory is segmented. However, the two methods can be combined. In this case, the memory is divided into pages or frames. Segments occupy multiple pages, and virtual addresses include segment numbers and page numbers.
Other page replacement methods include the First Input-First Output method, the Optimal Page Algorithm, and the LRU, which are less commonly used recently. The FIFO (first input-first output) algorithm has memory and replaces older pages that have been in the virtual address for a long time with new ones.
The optimal page algorithm method selects the pages to be replaced based on which page is less likely to be used after the longest possible time. Although this method is difficult to implement, it results in fewer page errors. The LRU screen replacement method replaces a page that has been unused for a long time in the main memory.
How to manage virtual memory
Managing virtual memory on an operating system is fairly straightforward, as there are default settings that determine the amount of hard disk space that is allocated to virtual memory. These settings will work for most applications and applications, but there may be situations where the amount of hard disk space allocated to virtual memory needs to be reset manually - for example, when working with applications that run on time. The quick response depends on when the computer has multiple hard drives (HDDs).
When manually resetting the virtual memory, the minimum and maximum amount of usable hard disk space that can be used must be specified. Allocating too little HDD space to virtual memory can fill up your computer's RAM. If a system constantly needs more virtual memory space, increasing RAM is a wiser solution. Conventional operating systems may generally advise users not to increase virtual memory by more than 1.5 times the amount of RAM.
Virtual memory management varies by the operating system. For this reason, IT professionals need to master the basics of topics such as physical memory management, virtual addresses, and virtual memory.
RAM cells in SSDs also have a limited lifespan. In RAM cells, the number of writes is limited, so using them for virtual memory often shortens the life of the drive.
What are the benefits of using virtual memory?
The advantages of using virtual memory are:
- It can handle twice as many addresses as the main memory.
- It can enable most applications to run at least once.
- Releases applications from shared memory management, and the user no longer has to use additional memory modules when RAM runs out.
- Increases speed when only one segment of an application is required to run.
- Increases security due to memory allocation.
- Allows several larger programs to run simultaneously.
- Memory allocation is relatively inexpensive.
- No need for external fragmentation.
- CPU utilization is efficient for managing logical partitioning workloads.
- Data can be transferred automatically.
- During the fork operation, which creates a copy of itself; Allows sharing of pages in the main process.
- If programs run from virtual memory, their execution speed will slow down.
- Data must be mapped between virtual and physical memory; This requires additional hardware support for translating addresses and slows down the computer further.
- Virtual storage size is limited due to the size of the secondary storage and the addressing scheme with the computer system.
- If not enough RAM, trashing may occur, slowing down the computer.
- Switching between applications using virtual memory can be time-consuming.
- Reduces the space available on the hard drive.
Virtual memory | RAM |
Uses a segment of physical memory | Physical memory |
Slower | Faster |
Use pagination | Use swapping techniques |
Limited by the size of physical memory | Limited by RAM chip size |
Does not have direct access to the CPU | It can access the CPU directly |
Limited depending on the size of the computer hard drive | RAM can be increased by installing more RAM chips |
0 Comments