Linux memory usage, swap, cache, and buffer

Source: Internet
Author: User

First, we will introduce how the memory is used in linux.
When an application needs to read and write disk data, the system reads the relevant data from the disk to the memory. If the physical memory is insufficient, some data in the memory is imported to the disk, in this way, part of the disk space is used as virtual memory, also known as Swap. If enough memory is allocated to all applications and the physical memory is still available, linux will try its best to use the idle memory to improve the overall I/O efficiency, the method is to divide the remaining memory into cache and buffer for utilization.
After the data read from the disk to the memory is read by the relevant application, if the remaining memory exists, the data will be stored in the cache for 2nd reads to avoid re-reading the disk. After an application modifies data in the memory, because the write speed to the disk is relatively low, in the case of idle memory, the data is first stored in the buffer and then written to the disk at a later time, therefore, the application can continue subsequent operations without waiting for the data to be written to the disk.
If the system requires more memory at a certain time point, the cache part will be erased, and the buffer content will be written to the disk, so that the two parts of memory will be released to the system for use, in this way, you need to read the content from the disk again.
Through the above analysis, we can know that the idle physical memory is not much, which does not necessarily indicate that the system is in poor running status, because the cache and buffer of the memory can be reused at any time. In a sense, these two parts of memory can also be viewed as additional idle memory for poetry. If swap is frequently called and bi and bo are not 0 for a long time, it is the basis for memory resource shortage.

 

Original article: http://jar-c.blog.163.com/blog/static/1164012502010325115534699/

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.