High memory usage in Linux

Source: Internet
Author: User

From:

Http://bailkai.blog.163.com/blog/static/82011736200910245110422/

Recently, I had a problem with my menstruation. Someone asked me why I had no other services and MEM was used up after I started the system? Is memory leakage? Do you want to restart the service? The root cause of the problem can be found only when the problem is not viewed.

This result is often given, and the memory usage is suspected to be 90%:

Mem: 4146788 k total, 3825536 K used, 321252 K free, 213488 K Buffers

Swap: 2650684 k total, 80 K used, 2650604 K free, 3006404 K cached

This suspicion is common because many people are familiar with windows. In Windows, you can use the task manager to view the memory consumption of the current process. In my opinion, Windows physical memory always leaves a certain amount of space, even if the physical memory is idle at this time, it will make someProgramThe purpose of using virtual memory is to allocate idle physical memory directly when a new program is started in windows, so that the startup speed of the new program is faster, whereas that of Linux is not.

In Linux, use the top command to view memory usage:

Mem: 4146788 k total, 3825536 K used, 321252 K free, 213488 K Buffers

Swap: 2650684 k total, 80 K used, 2650604 K free, 3006404 K cached

Here the result shows that the 90% GB used is used, and the usage reaches. You can also compare the free results:

$ Free-m

Total used free shared buffers cached

Mem: 4049 3784 265 0 208 2939

-/+ Buffers/cache: 636 3413

Swap: 2588 0 2588

Although mem displays used of about 636 GB, but (-/+ buffers/cache) minus buffers and cache, we can see that the actual memory occupied by the current process is MB, the available free memory is 3.4 GB.

It can be understood that in the memory allocation mechanism of Linux, the physical memory is preferentially used. When the physical memory is idle (enough), the occupied memory is not released, even if the program that occupies the memory has been disabled, the memory occupied by the program is used for Cache Usage. It is faster for the program that has been enabled or to read the data that has just been accessed.

In the preceding example, 4 GB memory is used, and GB memory is occupied. However, the buuffer and cached parts are used as cache, And the hit rate can be used to improve the efficiency, in addition, this part of cache can be released at any time according to commands. We can think that this part of memory is not actually used, or that it is idle.

Therefore, check whether the current process is actually using the memory, which is used-(buffers + cache). You can also think that if swap is not used in large quantities, Mem is enough, swap is used only when mem is occupied by the current process (without buffers and cache.

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.