Saturday, April 28, 2018

linux - Process claims to use a lot of memory, but 'free' indicates that the memory is still free

I've seen the opposite of this, but this is puzzling.



In short, I have a process where %MEM claims to use 74% of memory when using 'ps' and 'top'. However, 'free' shows that I'm only using 32% of the available memory.




Here is this output of 'top':



top - 18:25:49 up 203 days, 14 min,  1 user,  load average: 3.48, 3.75, 3.79
Tasks: 349 total, 1 running, 347 sleeping, 1 stopped, 0 zombie
Cpu(s): 10.3%us, 4.7%sy, 0.0%ni, 75.1%id, 6.5%wa, 0.0%hi, 3.4%si,0.0%st
Mem: 189.054G total, 188.280G used, 793.473M free, 253.570M buffers
Swap: 4095.996M total, 967.234M used, 3128.762M free, 126.370G cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

14416 root 20 0 165g 139g 81g S 250.3 74.0 764266:39 asd
30660 root 20 0 15164 1328 836 R 2.0 0.0 0:00.01 top


You will notice that the 'asd' process claims to use 74% (139g) of the available RAM. If you look at the total memory used - the cached memory (188-126), it looks like the entire system is only using 62G. That is obviously much lower that the one process 'asd' claims to use.



'free' is just as confusing. It shows 61G free:



# free -g
total used free shared buffers cached

Mem: 189 188 0 81 0 126
-/+ buffers/cache: 61 127
Swap: 3 0 3


'ps' seems to agree with the process listing in 'top':



# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 14416 261 74.0 173381464 146791980 ? Ssl Jan25 764310:00 /usr/bin/asd



I understand why 'free' would claim there is less memory available than 'top', but I don't see how a process can claim to use more RAM than the overall system reports as 'used'.



UPDATE:
I don't think this is the same as the posts you pointed me to Tim. Those appear to reference the opposite issue where people either mis-read the 'free' output and don't take into account the cache and buffers. Consequently, they can't find processes that are using the memory they think 'free' is claiming to use. In my case, I have a process that is claiming to use a lot of memory, but 'free' seems to think that memory is still available.

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...