Solution to high memory usage in Linux

Source: Internet
Author: User

In Linux, the memory usage is too high. The solution has recently encountered a menstrual problem. Some old people have asked why there are no other services after the boot, so mem will be used up? 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 we suspect that the memory uses 90%: www.2cto.com Mem: 4146788 k total, 3825536 k used, 321252 k free, 213488 k buffersSwap: 2650684 k total, 80 k used, 2650604 k free, 3006404 k cached is widely suspected because many people use 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, some programs will use the virtual memory to start new programs in Windows, directly allocate idle physical memory, which means the new program starts faster, but not Linux. In Linux, the top command shows memory usage: Mem: 4146788 k total, 3825536 k used, 321252 k free, 213488 k buffersSwap: 2650684 k total, 80 k used, 2650604 k free, 3006404 k cached the result here shows that the 90% GB used is used, and the usage reaches. You can also compare the free results: www.2cto.com $ free-mtotal used free shared buffers cachedMem: 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.

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.