Linux Memory Cache/buffer Profiling

Source: Internet
Author: User

Query free memory/memory usage status in Linux system View/remaining memory view

  

How to calculate the amount of memory used and the amount of idle

Physical used memory = actual used memory-buffered-cache

= 24752-2839-15049

Physical free memory = Total physical memory-Actual used memory + buffer + Cache

= 32073-24752 + 2839 + 15049

Application free memory = Total physical memory-actual memory used

= 32073-24752

Application used memory = actual used memory-buffered-cache

= 24752-2389-15049

  1. Buffer (buffered) is designed to improve the speed of data exchange between memory and hard disk (or other I/O devices).

2. Cache (Cached)   In terms of memory read and disk read, the cache can be understood as an operating system that uses memory to cache data that might be accessed again for higher read efficiency.

  
In a nutshell, buffer is about to be written to disk, and the cache is read from disk. Buffer is allocated by various processes and is used in areas such as input queues. A simple example is when a process requires multiple fields to be read, and before all fields are read into full, the process saves the previously read-in fields in buffer.

  

The basic principle of Linux is that no resources should be wasted. Therefore, the core uses as much RAM as possible to cache information from local and remote file systems. When the system does read and write operations, The data associated with the currently running process is stored in RAM as much as possible. The system-reported cache is the sum of both the buffer and the page cache. The cache is not recycled at the end of the process (you may start another process soon, requires the same data), but is recycled on demand – for example, When you start a process that requires a lot of memory, the Linux kernel reclaims the cache from memory and allocates the resulting memory to the new process.

Memory: From the user's and operating system's point of view, there is a difference in size and space. Like the memory of buffer/cached, because this memory is actually used from the operating system angle, but if the user wants to use, this block of memory can be quickly recycled and used by the user space program, so from the user's point of view this memory should be marked as idle state.

Why does Linux have this mechanism?

In fact, this is a very good design, in order to improve the performance of disk IO, the data read from the low-speed block device is temporarily saved in memory, even if the data is no longer needed at the time, but the next time the application accesses the data, it can be directly read from memory, thus bypassing the low-speed block device, thereby improving the overall performance of the system.

Linux Memory Cache/buffer Profiling

Related Article

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.