Linux Memory Usage : (actual physical memory)
Linux 'ps aux ' list on mem usage is vague.
{{ Read this FIRST }} if you want to get an idea of memory usage.
( you got 63 Gig free out of 66Gig - approx )
RSS lists shared libraries.
Physical_Dirty size inside each process at /proc/<procid>smaps file is right one (close to reality).
So, sum these dudes.
memusage.sh (lifted from blogs )
{{ Read this FIRST }} if you want to get an idea of memory usage.
[root@fts-vm-prod ~]# cat /proc/meminfo | headmem Free = MemFree+Buffers+Cached+SwapCached.
MemTotal: 65979160 kB
MemFree: 998616 kB
Buffers: 144104 kB
Cached: 63197468 kB
SwapCached: 0 kB
( you got 63 Gig free out of 66Gig - approx )
[root@fts-vm-prod ~]# cat /proc/meminfo | head
MemTotal: 65979160 kB ç 65979160 / 1024 = 64432 MB
MemFree: 998616 kB ç WRONG. ( Add buffers and Cached to it.)
Buffers: 144104 kB
Cached: 63197468 kB ç 63197468 / 1024 = 61716
MB FREE
SwapCached: 0 kB
mem Free = MemFree+Buffers+Cached+SwapCached.
( you got 63 Gig free out of
66Gig - approx )
RSS lists shared libraries.
Physical_Dirty size inside each process at /proc/<procid>smaps file is right one (close to reality).
So, sum these dudes.
memusage.sh (lifted from blogs )
#!/bin/sh
for i in /proc/[0-9]*; do
grep -q 'Private_Dirty' $i/smaps;
if [ $? -ne 0 ]; then
continue;
fi;
echo -n "${i}: ";
awk '/Private_Dirty/ {print $2,$3}' $i/smaps |
sed 's/ tB/*1024 gB/;s/ gB/*1024 mB/;s/ mB/*1024 kB/;s/ kB/*1024/;1!s/^/+/;' |
tr -d '\n' |
sed 's/$/\n/' |
bc |
tr -d '\n';
echo;
done |
sort -n -k 2
./memusage.sh | awk ' { print $2 } ' |xargs | sed -e 's/\ /+/g' | bc
