Linux memory management-free learning experience

Source: Internet
Author: User

Linux memory management-free learning experience

The free command can display idle and used physical memory, swap memory, and buffer used by the kernel in Linux. In Linux system monitoring tools, the free command is one of the most frequently used commands. The following is an example of a free command:

1 [root@bkjia ~]# free2              total       used       free     shared    buffers     cached3 Mem:       8062392    2092832    5969560          0     187132    14988324 -/+ buffers/cache:     406868    76555245 Swap:      2097148          0    2097148

The output result of this command is as follows:

The first line shows the memory details, such as the total memory, used memory, idle memory, memory shared by multiple processes, memory used for the buffer, and memory used for the cache.

Row 2: displays the total buffer memory/cache memory usage and idle conditions. The second row uses used total memory (2092832)-used buffer memory (187132)-used cache memory (1498832) = 406868. idle is the total (8062392)-used cache/buffer memory (406868) = 7655524.

Row 3: displays the total swap area memory, used memory, and idle memory. The swap area is the virtual memory created on the HDD to increase the virtual memory size. The problem arises:

What is the difference between a buffer and a slowdown?

A buffer is the place where data is temporarily stored for a specific application, and the data cannot be used by other applications. This is similar to the concept of bandwidth. When you try to transmit unexpected data over the network, if your network adapter can only send a small amount of data, it can store the large amount of data in the buffer, so that it can send the data at a lower speed acceptable to the network card. On the other hand, caching stores frequently used data for faster access. The other difference is that the cache can be used multiple times and the buffer can only be used once. However, they all provide a temporary storage for your data processing. The following describes how to use these chestnuts.

Chestnuts used by the free command

1. Display memory in MB (commonly used)

-M:

1 [root@bkjia ~]# free -m2              total       used       free     shared    buffers     cached3 Mem:          7873       2043       5829          0        182       14634 -/+ buffers/cache:        397       74765 Swap:         2047          0       2047

2. Memory displayed in bytes, kilobytes, and gigabytes (not commonly used)

Use the-B,-k, and-g parameters to display the memory size in bytes, kilobytes, and gigabytes:

1 [root@bkjia ~]# free -b2              total       used       free     shared    buffers     cached3 Mem:    8255889408 2142736384 6113153024          0  191623168 15348039684 -/+ buffers/cache:  416309248 78395801605 Swap:   2147479552          0 2147479552

3. display the total usage

Use the-t parameter to display the total usage with one more row of total:

1 [root@bkjia ~]# free -t2              total       used       free     shared    buffers     cached3 Mem:       8062392    2092516    5969876          0     187132    14988324 -/+ buffers/cache:     406552    76558405 Swap:      2097148          0    20971486 Total:    10159540    2092516    8067024

4. Disable the line that shows the buffer.

Use the-o parameter to disable the display of the second line:

1 [root@bkjia ~]# free -o2              total       used       free     shared    buffers     cached3 Mem:       8062392    2092764    5969628          0     187132    14988324 Swap:      2097148          0    2097148

5. Update the current memory usage at a fixed interval

Add the-s parameter and add an integer after the-s parameter to update the memory usage at regular intervals. Let's take an example and add an integer, update once within S:

1 [root@bkjia ~]# free -o2              total       used       free     shared    buffers     cached3 Mem:       8062392    2092764    5969628          0     187132    14988324 Swap:      2097148          0    2097148

6. Additional display of low and high memory statistics

Use the-l parameter to display the low and high memory size statistics:

 
1 [root@bkjia ~]# free -l2              total       used       free     shared    buffers     cached3 Mem:       8062392    2092516    5969876          0     187132    14988324 Low:       8062392    2092516    59698765 High:            0          0          06 -/+ buffers/cache:     406552    76558407 Swap:      2097148          0    2097148
 

7. view the free command version

Use the-V parameter to display version information:

1 [root@bkjia ~]# free -V2 procps version 3.2.8

Above.

Linux memory management-free command

This article permanently updates the link address:

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.