Answer the question
In order to leave comments, you need to log in
How to find out where RAM goes in Linux?
I can't figure out where the memory is being lost.
The fact is that the sum of the processes in ps shows one thing, and the available memory (counted as inactive + free + cached) is completely different.
The difference is 10 gigabytes. There is a suspicion that something is leaking, but the memory is not released, even after the process ends.
Memory collection checked with a simple bash code
#!/bin/sh
d=`date +%F_%H`
f=/root/vm_utilize/$d.log
ps axu | awk '{print $11 " " $5}' | grep -v ' 0$' | grep -v VSZ >> $f
sum=0
for i in `ps axu | awk '{print $5}' | grep -v VSZ`; do
sum=$(($sum + $i))
done
echo $sum >> $f
Answer the question
In order to leave comments, you need to log in
To dispel doubts.
Here is an example (free or cat /proc/meminfo):
MemTotal: 32,880,924 kB
MemFree: 12,564,540 kB
Buffers: 366,052 kB
Cached: 4,967,724 kB
Inactive: 2,853,512 kB
Total free 20,385,776
Sum by processes at the same time - 8 839 420 kB (counted through ps - the code was written above). Somewhere else ~ 4 GB of memory has gone.
What do you think - what is the flaw here?
==============================
UPD
Question closed.
Described here:
forum.openvz.org/index.php?t=msg&goto=48093&
There is a solution:
sync && echo 2 >/proc/sys/vm/drop_caches
Additional discussion here:
All memory gradually goes under Cached
linsovet.org.ua/content/linux-flush-system-caches
Why do top and free show that the memory is busy when they are not?
www.linuxatemyram.ru
the funniest thing about these tips is that you really can’t check where the leak is, and where is the garbage that the system, you see, decided to transfer to the RAM;). they also often write about android that it will free up memory as needed .. the need comes and your phone decides to reboot ... because you see, it doesn’t even have enough memory for system tasks.
www.linuxatemyram.ru
welinux.ru/post/2388
Well, you probably thought wrong.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question