How does one query the real memory usage in Linux?

Source: Internet
Author: User

Using the top tool, we can see that SuSE Linux has a high memory usage, which may be more than 97%. I know this is a Linux memory usage mechanism. First, we can manage the entire memory, when necessary, it is allocated to a single process. However, if I need to check the real memory usage of the system, what should I do?

 

The following shows the usage of the current memory.-M indicates that the content is displayed in MB bytes. Let's take a look.

$ Free-m
            Total     Used     Free   Shared  Buffers   Cached
Mem:       1002      769      232        0       62      421
-/+ Buffers/cache:      286      715
Swap:       1153        0     1153

---------------------------

Actual memory usage = used-Buffers-cached = 286

-----------------

 


Part 1 mem row:
Total memory: 1002 MB
Used memory used: 769 MB
Free idle memory: 232 MB
Shared is no longer used. It is always 0.
Buffers buffer cache memory: 62 MB
Cached page cache memory: 421 MB

Link: Total (1002 m) = used (769 m) + free (232 m)

Part 2 (-/+ buffers/cache ):
(-Buffers/cache) used memory size: 286 MB (refers to used-Buffers-cached in the first part of the mem row)
(+ Buffers/cache) free memory: 715 MB (refers to the first part of the mem row free + buffers + cached)

It can be seen that-Buffers/cache reflects the memory actually eaten by the program, while + buffers/cache reflects the total number of memories that can be used.

The third part refers to swap partitions,

I think you are still dizzy after reading the above. The first part (MEM) and the second part (-/+ buffers/cache) are so strange about used and free.
In fact, we can explain it in two ways.
For the operating system, it is the mem parameter. buffers/cached are all used, so it is considered that free is only 232.
For applications (-/+ buffers/cach ). buffers/cached is equivalent to available, because buffer/cached is used to improve the performance of program execution. When the program uses memory, buffer/cached will be quickly used.

So let's take a look at the application. The free and used of (-/+ buffers/cache) are the main ones. so let's just look at this. in addition, I would like to tell you some common sense. in order to improve disk and memory access efficiency, Linux has made a lot of elaborate designs, in addition to caching dentry (for VFS, accelerating file path name conversion to inode ), two major cache methods are also adopted: buffer cache and page cache. The former is used to read and write disk blocks, and the latter is used to read and write inode files. These caches can effectively shorten the time for I/O system calls (such as read, write, getdents.

Remember that the memory is used, not for reference. unlike windows, no matter how much physical memory you have, you need to read it from the hard disk swap file. this is why Windows often prompts insufficient virtual space. think about it. It's boring. When there is still a large amount of memory, you can use some hard disk space to act as the memory. how is the hard disk faster than the memory. therefore, in Linux, as long as the swap space of swap is not used, we don't have to worry about having too little memory. if many swap instances are used, you may need to add physical memory. this is also the Standard for Linux to check whether the memory is sufficient.

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.