How to view physical memory usage under Linux systems

Source: Internet
Author: User

How to view physical memory usage under Linux systems

Linux looks at memory and CPU usage generally with the top command, but the actual use, the top view of the memory usage is very high, such as:
mem:4086496k Total, 4034428k used, 52068k free, 112620k buffers
swap:4192956k Total, 799952k used, 3393004k free, 1831700k cached

Close to 98.7%, while the actual application consumes less memory often,

PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND
25801 Sybase 0 2648m 806m 805m S 1.0 20.2 27:56.96 DataServer
12084 Oracle 0 1294m 741m 719m S 0.0 18.6 0:13.50 Oracle
27576 Xugy 0 986m 210m 1040 S 1.0 5.3 28:51.24 CTI
25587 Yaoyang 0 1206m 162m 3792 S 0.0 4.1 9:21.14 java

See%mem This column of numbers, according to the memory sort, put the first several add up, support dead only 55%, that the rest of the memory is why use?

The general explanation is that the Linux system has a thought, the memory does not need to be white, takes up does not release, sounds a bit reasonable, but if I must know how much memory the application can be available?

Look closely at the top of the memory display output, there are two data buffers and cached, in the Linux system buffer refers to the disk write cache, and the cache refers to the disk read cache.
(A buffer is something that have yet to being "written" to disk.)
A cache is something that have been "read" from the disk and stored for later use.)


These two pieces are allocated to improve the system efficiency of memory, when the memory surplus, the operating system to use the free memory, and memory requirements, the system will release this part of the memory for the application to use.

In this way, the memory available to the real application is Free+buffer+cache, and the example above is:
52068k + 112620k + 1831700k = 1996388k

While the used memory is Used-buffer-cache, the above example is:
4034428k-112620k-1831700k = 2090108k

There is a more convenient command for viewing memory under Linux, free:
$ free
Total used free shared buffers Cached
mem:4086496 4034044 52452 0 112756 1831564
-/+ buffers/cache:2089724 1996772
swap:4192956 799952 3393004

Mem: This is the memory usage you see with the top command, and-/+buffers/cache is the result of the calculations we just made, Used-buffer-cache/free+buffer+cache

You can also add the-m or-G parameters to view the results by MB or GB conversion.


$ free-m
Total used free shared buffers Cached
mem:3990 3906 83 0 90 1786
-/+ buffers/cache:2029 1961
swap:4094 781 3312

In this way, the memory usage of the real application can be derived, the above example, the memory occupancy rate is 51.1%.

From http://www.linuxidc.com/Linux/2012-08/67839.htm

How to view physical memory usage under Linux systems

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.