Basic Swap partition knowledge

Source: Internet
Author: User

Swap partition, that is, Swap zone. How many people care about it except when installing Linux? In fact, the adjustment of Swap partitions is crucial to the performance of Linux servers, especially Web servers. By adjusting the Swap partition, you can sometimes bypass the system performance bottleneck and reduce system upgrade costs.

The principle of Swap partitioning is a complicated issue that requires a large amount of space. Here, we will only give a brief introduction. We will discuss in detail the implementation details of Swap in future articles.

As we all know, modern operating systems have implemented the "virtual memory" technology, which not only breaks through the physical memory restrictions in terms of functionality, so that programs can manipulate space larger than the actual physical memory, more importantly, "Virtual Memory" isolates the security protection network of each process so that each process is not disturbed by other programs.

The role of the Swap space is described as follows: when the system's physical memory is insufficient, a part of the physical memory needs to be released for use by the currently running program. The released space may come from some programs that haven't been operated for a long time. The released space is temporarily saved to the Swap space and will be executed by those programs, then, the stored data is restored from the Swap partition to the memory. In this way, the system always performs Swap switching when the physical memory is insufficient.

Computer users often encounter this phenomenon. For example, when you use a Windows system, you can run multiple programs at the same time. When you switch to a program that has been ignored for a long time, you will hear the hard disk burst.

This is because the memory of this program is "stolen" by frequently running programs and put in the Swap partition. Therefore, once the program is placed on the front end, it will retrieve its data from the Swap area, put it into the memory, and then run.

It should be noted that not all data exchanged from the physical memory will be put into the Swap partition. If so, Swap will be overwhelmed ), A considerable amount of data is directly exchanged to the file system.

For example, some programs open some files and read and write the files. In fact, each program must open at least one file, that is, run the program itself ), when you need to Swap out the memory space of these programs, there is no need to put the data in the file part into the Swap partition space, and you can directly put it in the file.

If it is a file read operation, the memory data is directly released and does not need to be exchanged, because it can be directly restored from the file system when needed next time; if it is a file write operation, you only need to save the changed data to the file for recovery.

However, the data of objects generated using the malloc and new functions is different. They need Swap partition space because they do not have the corresponding "reserve" file in the file system, therefore, it is called "Anonymous" (Anonymous) memory data. This type of data also includes some status and variable data in the stack. Therefore, the Swap space is the Swap space for "anonymous" data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.