Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the virtual memory in linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what is virtual memory in linux", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what is virtual memory in linux".

1. Discuss warm-up in front of virtual memory

What we need to know is that the computer divides memory into physical memory and virtual memory (note the difference between virtual memory and virtual address space). Physical memory is the actual memory size of a computer and is made up of RAM chips. Virtual memory is virtual, using disks instead of memory.

two。 How virtual memory works

As described earlier, when the system does not have enough physical memory, some of the physical memory needs to be freed for use by the currently running program.

The free space may come from programs that have not operated for a long time, and the free space is temporarily saved in the swap space, and then the saved data is recovered from the swap space into memory when those programs are about to run.

3. Implementation of Linux virtual memory

There are two ways to realize virtual memory in Linux system, which are swap partition (swap partition) and swap file.

Swap partition: swap partition is actually a new partition, and then mount that partition as swap space, the method is the same as the traditional new partition. It's just that formatting and mounting partitions use the mkswap and swapon commands, respectively.

Swap file: there is not enough space on the hard drive to create a swap partition, so we will manually create a swap file to swap the inactive contents of RAM into it.

4. Ideal exchange weight

Linux allows us to set the weight of the exchange, that is, we can set the frequency of the exchange process. Friends can set the exchange weight between 0 and 100 as needed. A lower value means that the kernel uses less swap as much as possible, and the higher the value, the more the kernel uses swap space.

The default value and recommended value for swapping weights is 60. Interested partners can learn swappiness, the Linux kernel parameter, which is not described too much here.

5. Benefits of using virtual memory

It can easily save RAM blocks that are rarely used and occupied. The freed RAM can then be used to accommodate more programs with higher priorities.

Prevent the situation in which RAM space is used up and other programs cannot be executed.

Virtual memory acts as a backup of RAM, thus increasing the actual space of RAM.

During hibernation, all the contents of the RAM are written to swap space. Therefore, virtual memory is required for successful hibernation.

It improves the overall performance of the system. (if the kernel parameter swappiness is set properly)

These are all the contents of the article "what is virtual memory in linux?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report