As noted at How to measure actual memory usage of an application or process?:
Why ps is "wrong"
Depending on how you look at it, ps is not reporting the real memory usage of processes. What it is really doing is showing how much
real memory each process would take up if it were the only process
running. Of course, a typical Linux machine has several dozen
processes running at any given time, which means that the VSZ and RSS
numbers reported by ps are almost definitely "wrong".
So your ps command will tend to OVERCOUNT the memory used by processes, as it double-counts memory that is shared.
On the other hand, I can see you are looking at the correct line of the free output which discards the memory used for buffers/cache. You need to look in /proc/meminfo
to see what is using up most of the discrepancy in RAM, as discussed at https://serverfault.com/questions/240277/slab-uses-88gb-of-128gb-available-what-could-cause-this.
Slab cache is separate from the buffers/cache reported by free, so assuming it is responsible for most of the discrepancy you can see what it is used for in /proc/slabinfo
. If it's dentries (dentry_cache
line) or inodes (there are many *inode_cache
lines), you can use the following to free up the RAM:
sync; echo 2 >/proc/sys/vm/drop_caches
to get rid of them.