Today, someone told me that the memory on the Linux server is not fast enough, 128G of memory, will be used up immediately. I was startled, the application on this server is now very small, ah, how the utilization will be very high. First use Zabbix to see the next, memory remaining space is still very big, there is 117G of spare ah. Then log on to the server again and look at:
[[Email protected] ~]$ toptop- One: A:GenevaUp415Days1: .,2Users, load average:0.17,0.12,0.28Tasks:847Total1Running846Sleeping,0Stopped0Zombiecpu (s):1.0%us,0.7%sy,0.0%ni,98.3%id,0.0%wa,0.0%hi,0.0%si,0.0%stmem:132035736k Total, 130251764k used, 1783972k free, 679012k buffersswap:16777212k total, 448004k used, 163 29208k free, 120309904k cached PID USER PR NI VIRT RES SHR S%CPU%MEM time+COMMAND48069Oracle - 0 -.1g 299m 213m S7.2 0.2 23205: -Oracle5197Root RT0756m 88m 57m S3.6 0.1 36032: theOsysmond.bin5376Root RT-5693m 154m 63m S2.3 0.1 11577: GenevaOloggerd5924Grid-2 01306m 14m 12m S1.6 0.0 9131: AOracle48055Oracle-2 0 -.0g 17m 15m S1.6 0.0 9306: theOracle6283Root - 0968m 28m 12m S1.3 0.0 5426: AOrarootagent.bi4563Root - 01914m 55m 14m S1.0 0.0 3451: AOhasd.bin48109Oracle - 0 -.0g 813m 808m S1.0 0.6 5880: .Oracle86867Root - 02273m 240m 10m S1.0 0.2 458:42.00Ds_am146406Oracle - 0 15568 1844 932R1.0 0.0 0:00.22Top5183Root - 01763m 39m 14m S0.7 0.0 3144: +Orarootagent.bi
Look at the mem item, sure enough, the utilization is very high, free is not much. Then use the free command to see:
[Email protected] ~]$ free total used free shared buffers cachedmem: 132035736 130258872 1776864 59092256 679016 120313028-/+ buffers/cache: 9266828 122768908Swap: 16777212 448004 16329208 [[Email protected]
The same is true. Thus, turn over the universal degree Niang, found the relevant information on the Internet. In the Linux memory allocation mechanism, the first use of physical memory, when the physical memory is idle (enough), does not release its memory consumption, even if the memory-hogging program has been shut down, the program occupied by the memory used for cache use, for open programs, or read just accessed data will be faster.
The following is the original content:
Recently there is a menstrual problem, the old people asked why after the boot, there is no other services, MEM is exhausted? Is it a memory leak? Do you want to restart the service? Can only say not to see the phenomenon, to see the essence to find the root of the problem.
Often given such a result, suspect memory is used for 90%:
mem:4146788k Total, 3825536k used, 321252k free, 213488k buffers
swap:2650684k Total, 80k used, 2650604k free, 3006404k cached
This suspicion is common because many people are accustomed to windows. Under Windows, you can use 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 existence of idle, it will let some programs to use virtual memory, in order to start a new program under Windows, the direct allocation of free physical memory, this way the new program starts faster, and Linux is not.
Under Linux, use the top command to see memory usage:
mem:4146788k Total, 3825536k used, 321252k free, 213488k buffers
swap:2650684k Total, 80k used, 2650604k free, 3006404k cached
The results show that 3.8G used is used, with a occupancy rate of 90%. Look at the results of free you can also compare:
$ 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 shows a used of around 3.7G, the results of the-/+ Buffers/cache minus buffers and cache can be seen, the current process actually consumes 636M of memory, and free memory is 3.4G.
It can be understood that in the memory allocation mechanism of Linux, the first use of physical memory, when the physical memory is idle (enough), does not release its memory consumption, even if the memory-hogging program has been shut down, the program occupies the memory used for cache use, for open programs, Or reading the data that has just been accessed will be faster.
As the above example: the use of 4G of memory, 3.7G is occupied, but the buuffer and cached parts as a cache, you can use hit rate to improve the efficiency of use, and this part of the cache is ready to release according to the instructions, we can think that this part of the memory is not actually used, You can also think of it as free.
So look at the memory currently being used by the process is used-(Buffers+cache), it can also be considered that if swap is not heavily used, mem is sufficient, only the mem is actually occupied by the current process (without the buffers and cache), will only be used for swap.
According to the above content, I forget, do not have a lot of memory remaining. The original Zabbix is still credible, cause I am nervous or due to the Linux memory allocation mechanism is not clear caused.
Why is my linux server memory utilization high? Understand the Linux memory usage mechanism correctly