blog posts

What is Virtual Memory? Disadvantages, advantages and Methods of doing

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. 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.

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.

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 management technique based on which secondary memory can be used as part of the main memory. Also, 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), to be freed up RAM space.

Virtual memory to improve system performance, multitasking, and use of 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 the RAM space will be short if several programs want to run simultaneously. 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 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 RAM space is urgently needed for a subject anywhere, data can be transferred from RAM to virtual memory.

The computer memory management unit tracks and tracks these transfers between virtual and physical memory. The computer MMU uses the context switch to resume execution if the data is needed again.

When copying virtual memory into physical memory, the OS divides the memory by the number of addresses or page files or swap files, 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, 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. It 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 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 size of a computer’s physical memory.

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 show whether the page exists in Rome. Suppose an operating system or application does not find what it needs in Rome. In that case, 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 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 have been 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. However, this method is difficult to implement, and there are 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 default settings determine the amount of hard disk space allocated to virtual memory. These settings will work for most applications. Still, there may be times when the amount of hard disk space allocated to virtual memory needs to be reset manually – for example, when working with applications that are timed out. 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. Increasing RAM is a wiser solution if a system constantly needs more virtual memory space. Conventional operating systems may generally advise users not to increase virtual memory to 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 drive’s life.

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.
  • Using CPU to manage workload partitioning is logically efficient.
  • Data can be transferred automatically.
  • The fork operation, which creates a copy of itself, Allows sharing of pages in the main process.

In addition to these benefits, in a virtualized computing environment, network administrators can allocate everything from user virtual memory management methods to memory to a virtual machine (VM) that requires a lot of memory to run.

What are the limitations of using virtual memory?

Although there are benefits to using virtual memory, there are some considerations that need to be considered, such as:

  • 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 there is not enough RAM, trashing may occur and they are slowing down the computer.
  • Switching between applications using virtual memory can be time-consuming.
  • Reduces the space on the hard drive.

Virtual memory usage history

Before developing and using virtual memory, computers had RAM and secondary memory. Newer computers used magnetic core memory for primary memory and magnetic drums for secondary memory. Computer memory was usually expensive and scarce until the 1940s and 1950s. As the size and complexity of computer programs progressed, developers became more concerned that their programs would use up their main memory and run out of computer memory.

In the early days, programmers used overlaying to run programs that were larger than the available memory. Parts of the program that are not used consistently are set to overlay, and existing overlays will be overwritten when needed. This requires extensive programming to do the overlaying work, which is the main motivation for developing and using virtual memory.

The German physicist Fritz Rudolf Gontsch became famous in 1956 for developing and using virtual memory, although this was later discussed. Nevertheless, Gunesh eventually described and introduced a type of cache.

The first real-world example of a virtual memory system was provided by the University of Manchester in Manchester, England, to develop and expand the single-level memory system for the Atlas computer. The system uses pagination to map virtual addresses to a programmer on the main memory. Atlas was developed in 1959 and later launched in 1962.

In 1961, the first commercial computer with virtual memory was introduced by Burroughs. In this virtual memory version, segmentation methods were used instead of pagination.

Conclusion

In 1969, IBM researchers showed that virtual memory storage systems performed better than older handheld systems. This issue is still under discussion, and there are doubts about it. Mainframes (minicomputers) and minicomputers in the 1979s generally used virtual memory. Virtual memory technology was not used in early PCs because the developers believed running out of memory could not be a problem for these computers. This hypothesis was later proved to be incorrect. Intel introduced virtual memory in the 80286 processor protected state in 1982; It also introduced pagination support when the 80386 was introduced in 1985.