free -m
total used free shared buffers cached
Mem: 16318 15745 573 6548 174 8062
-/+ buffers/cache: 7508 8810
Swap: 12283 2422 9861
Note: tmpfs and shared memory segments count toward pagecache! |
sync; echo 3 > /proc/sys/vm/drop_caches
MemTotal: 16710208 kB
MemFree: 590720 kB
MemAvailable: 1662528 kB
Buffers: 178688 kB
Cached: 8069248 kB
SwapCached: 74560 kB
Active: 11600512 kB
Inactive: 1729024 kB
Active(anon): 10658816 kB
Inactive(anon): 1159424 kB
Active(file): 941696 kB
Inactive(file): 569600 kB
Unevictable: 150336 kB
Mlocked: 150336 kB
SwapTotal: 12578688 kB
SwapFree: 10097792 kB
Dirty: 1984 kB
Writeback: 0 kB
AnonPages: 5164224 kB
Mapped: 6361984 kB
Shmem: 6705536 kB
Slab: 380800 kB
SReclaimable: 112192 kB
SUnreclaim: 268608 kB
KernelStack: 11904 kB
PageTables: 42880 kB
[...]
Active, Active(anon), Active(file) Recently used memory that will not be reclaimed unless necessary or on explicit request. Active is the sum of Active(anon) and Active(file):Active(anon) tracks swap-backed memory. This includes private and shared anony- mous mappings and private file pages after copy-on-write.Active(file) tracks other file system backed memory. Inactive, Inactive(anon), Inactive(file) Less recently used memory that will usually be reclaimed first. Inactive is the sum of Inac- tive(anon) and Inactive(file): Inactive(anon) tracks swap backed memory. This includes private and shared anonymous mappings and private file pages after copy-on-write. Inactive(file) tracks other file system backed memory. |
grep -i shmem /proc/memory
Shmem: 6705536 kB
ipcs -a
------ Message Queues --------
key msqid owner perms used-bytes messages
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00004dc4 125173760 sapadm 760 40141728 1
0x00004dbe 125206529 root 777 702916 1
0x000027bd 125370370 sidadm 740 60000000 1
0x00000000 229379 root 600 2610 0
0x00000000 262148 sidadm 740 1024 1
0x0382be85 294917 sidadm 640 4096 2
0x00002796 327686 sidadm 740 131072000 1
0x00000000 360455 sidadm 740 1024 1
0x0382be84 393224 sidadm 640 4096 21
0x00002749 425993 sidadm 740 2048592 20
0x0000271a 655370 sidadm 740 124000000 21
[…]
cleanipc <instance number> remove
Note: Do not use it when the system or any of its processes is still up and running. End all processes and check it with ps -fu <sidadm> |
For each individual process:
cat /proc/<PID>/smaps
grep -i slab -A 4 /proc/meminfo
Slab: 380800 kB
SReclaimable: 112192 kB
SUnreclaim: 268608 kB
KernelStack: 11904 kB
PageTables: 42880 kB
cat /proc/slabinfo
labinfo - version: 2.1
# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
SCTPv6 2 42 1536 42 1 : tunables 24 12 8 : slabdata 1 1 0
SCTP 0 0 1280 51 1 : tunables 24 12 8 : slabdata 0 0 0
nf_conntrack 211 762 256 254 1 : tunables 120 60 8 : slabdata 3 3 0
nfs_direct_cache 0 0 360 181 1 : tunables 54 27 8 : slabdata 0 0 0
nfs_inode_cache 7666 23373 1040 63 1 : tunables 24 12 8 : slabdata 371 371 0
rpc_inode_cache 0 0 640 102 1 : tunables 54 27 8 : slabdata 0 0 0
fscache_cookie_jar 4 799 80 799 1 : tunables 120 60 8 : slabdata 1 1 0
ext4_groupinfo_4k 360 448 144 448 1 : tunables 120 60 8 : slabdata 1 1 0
ext4_inode_cache 4136 5820 1080 60 1 : tunables 24 12 8 : slabdata 97 97 0
ext4_allocation_context 2 504 128 504 1 : tunables 120 60 8 : slabdata 1 1 0
[…]
Example:
25MB binary = > 50% loaded
200MB shared libraries (=shared memory) => 80% loaded
50MB heap => 75% used / loaded
10 Processes using the shared libs
VSZ: 25MB + 200MB + 50MB = 275MB
RSS: 25MB*0,5 + 200MB*0,8 + 50*0,75 = 210MB
PSS: 25MB*0,5 + 200MB*0,8/10 + 50*0,75 = 66MB
grep -e \- -e ^Size -e ^Rss -e ^Pss /proc/$(PID)/smaps
#!/bin/sh
p_name=$1
ps -eo pid,comm,cmd |grep $p_name | grep -v grep> /tmp/pid_name.out
awk '{print $1}' /tmp/pid_name.out > /tmp/pid.out
PID_file='/tmp/pid.out'
i=0
BAR='####################'
end=$(cat $PID_file |wc -l)
while read pid;
do
cmd=$(grep $pid /tmp/pid_name.out)
echo "##############" >> $2
echo "SMAPS: $pid" >> $2
echo "Process: $cmd" >> $2
echo "##############" >> $2
let i+=1
python <path-to-python-script-edit-here>/smaps_analyzer.py /proc/$pid/smaps Pss >> $2
status=$(($i * 100 / $end))
end_status=$(($end / 20 * $i))
echo -ne "\r${BAR:0:$end_status}"
echo $status "%"
sleep 0.1
done < $PID_file
rm /tmp/pid.out /tmp/pid_name.out
Usage:
./scriptname.sh <search_term> <output>
./pid_analyses.sh dw.sap /tmp/pid_analyses.out
##############
SMAPS: 560
Process: 560 SID_00_DIA_W6 dw.sapSID_D00 pf=/usr/sap/SID/SYS/profile/SID_D00_aldSIDd0
##############
all data
Pss Rss Size name other
268548 kB 2950720 kB 6434816 kB /dev/zero (deleted)
247235 kB 247296 kB 309248 kB [heap]
95080 kB 1100736 kB 1290240 kB /SYSV00002716 (deleted)
38419 kB 323072 kB 1752000 kB /SYSV00002738 (deleted)
17482 kB 17664 kB 83776 kB unknown
11517 kB 217920 kB 255680 kB /SYSV00002712 (deleted)
8910 kB 91200 kB 149440 kB /SYSV00002718 (deleted)
8300 kB 84928 kB 84928 kB /SYSV00002763 (deleted)
6476 kB 66176 kB 92288 kB /SYSV00002746 (deleted)
4761 kB 56832 kB 88832 kB /usr/sap/SID/D00/exe/disp+work
3472 kB 52480 kB 52544 kB /SYSV00002739 (deleted)
2517 kB 44096 kB 44096 kB /SYSV00002724 (deleted)
1478 kB 27200 kB 58816 kB /SYSV00002759 (deleted)
960 kB 960 kB 1152 kB [stack]
764 kB 16064 34304 kB /SYSV00002725 (deleted)
669 kB 6464 kB 12864 kB /usr/sap/SID/hdbclient/libSQLDBCHDB.so
617 kB 6976 kB 121152 kB /SYSV0000271a (deleted)
526 kB 8192 kB 13120 kB /SYSV00002743 (deleted)
428 kB 4992 kB 850048 kB /SYSV00002713 (deleted)
379 kB 3648 kB 4928 kB /usr/sap/SID/D00/exe/libsapcrypto.so
269 kB 1536 kB 2688 kB /usr/sap/SID/D00/exe/dbhdbslib.so
191 kB 2304 kB 176704 kB /SYSV0000274e (deleted)
164 kB 1216 kB 1728 kB /usr/sap/SID/D00/exe/dw_xml.so
135 kB 256 kB 21056 kB /usr/sap/SID/D00/exe/dw_gui.so
114 kB 896 kB 1920 kB /usr/sap/SID/D00/exe/libicuuc.so.50
101 kB 640 kB 5312 kB /usr/sap/SID/D00/exe/dw_abp.so
94 kB 512 kB 2496 kB /usr/sap/SID/D00/exe/libicui18n.so.50
93 kB 1152 kB 2240 kB /usr/lib64/libstdc++.so.6.0.25
90 kB 384 kB 832 kB /usr/sap/SID/D00/exe/dw_rndrt.so
88 kB 448 kB 2944 kB /usr/sap/SID/D00/exe/dw_xtc.so
86 kB 1600 kB 2048 kB /SYSV00002749 (deleted)
85 kB 1728 kB 1856 kB /lib64/libc-2.22.so
83 kB 384 kB 1152 kB /usr/sap/SID/D00/exe/libregex.so
75 kB 1088 kB 1088 kB /SYSV00002714 (deleted)
73 kB 1024 kB 4160 kB /SYSV00002751 (deleted)
71 kB 832 kB 4160 kB /SYSV00002750 (deleted)
70 kB 256 kB 256 kB /lib64/libgcc_s.so.1
68 kB 256 kB 256 kB /lib64/libpthread-2.22.so
68 kB 192 kB 192 kB /lib64/libnss_sss.so.2
68 kB 320 kB 320 kB /lib64/ld-2.22.so
67 kB 192 kB 192 kB /lib64/libnss_files-2.22.so
42 kB 576 kB 1216 kB /usr/sap/SID/D00/exe/dw_stl.so
67 kB 192 kB 192 kB /lib64/libnss_files-2.22.so
42 kB 576 kB 1216 kB /usr/sap/SID/D00/exe/dw_stl.so
40 kB 640 kB 6144 kB /SYSV00002722 (deleted)
30 kB 384 kB 20480 kB /usr/sap/SID/D00/exe/libicudata.so.50
27 kB 576 kB 896 kB /lib64/libm-2.22.so
9 kB 128 kB 192 kB /SYSV00002744 (deleted)
8 kB 256 kB 256 kB /lib64/libresolv-2.22.so
7 kB 128 kB 15680 kB /usr/sap/SID/D00/exe/librender.so
7 kB 128 kB 1920 kB /usr/sap/SID/D00/exe/libicuuc51.so
7 kB 128 kB 192 kB /usr/sap/SID/D00/exe/libiculx51.so
7 kB 128 kB 448 kB /usr/sap/SID/D00/exe/libicule51.so
7 kB 192 kB 192 kB /lib64/libnss_dns-2.22.so
6 kB 192 kB 192 kB /lib64/libdl-2.22.so
6 kB 64 kB 576 kB /SYSV00002748 (deleted)
5 kB 128 kB 192 kB /usr/lib64/libuuid.so.1.3.0
4 kB 128 kB 192 kB /lib64/librt-2.22.so
4 kB 64 kB 64 kB /SYSV00002761 (deleted)
4 kB 64 kB 64 kB /SYSV00002717 (deleted)
3 kB 64 kB 64 kB /usr/sap/SID/SIDadm/.hdb/sap-ald-138-s/SQLDBC.shm
3 kB 64 kB 21952 kB /usr/sap/SID/D00/exe/libicudata51.so
3 kB 64 kB 64 kB /SYSV0382be84 (deleted)
3 kB 64 kB 64 kB /SYSV0000272e (deleted)
3 kB 64 kB 64 kB /SYSV00002711 (deleted)
1 kB 128 kB 128 kB [vdso]
stack maps
Pss Rss Size name other
960 kB 960 kB 1152 kB [stack]
all so maps
Pss Rss Size name other
669 kB 6464 kB 12864 kB /usr/sap/SID/hdbclient/libSQLDBCHDB.so
379 kB 3648 kB 4928 kB /usr/sap/SID/D00/exe/libsapcrypto.so
269 kB 1536 kB 2688 kB /usr/sap/SID/D00/exe/dbhdbslib.so
164 kB 1216 kB 1728 kB /usr/sap/SID/D00/exe/dw_xml.so
135 kB 256 kB 21056 kB /usr/sap/SID/D00/exe/dw_gui.so
101 kB 640 kB 5312 kB /usr/sap/SID/D00/exe/dw_abp.so
90 kB 384 kB 832 kB /usr/sap/SID/D00/exe/dw_rndrt.so
88 kB 448 kB 2944 kB /usr/sap/SID/D00/exe/dw_xtc.so
85 kB 1728 kB 1856 kB /lib64/libc-2.22.so
83 kB 384 kB 1152 kB /usr/sap/SID/D00/exe/libregex.so
68 kB 256 kB 256 kB /lib64/libpthread-2.22.so
68 kB 320 kB 320 kB /lib64/ld-2.22.so
67 kB 192 kB 192 kB /lib64/libnss_files-2.22.so
42 kB 576 kB 1216 kB /usr/sap/SID/D00/exe/dw_stl.so
27 kB 576 kB 896 kB /lib64/libm-2.22.so
8 kB 256 kB 256 kB /lib64/libresolv-2.22.so
7 kB 128 kB 15680 kB /usr/sap/SID/D00/exe/librender.so
7 kB 128 kB 1920 kB /usr/sap/SID/D00/exe/libicuuc51.so
7 kB 128 kB 192 kB /usr/sap/SID/D00/exe/libiculx51.so
7 kB 128 kB 1920 kB /usr/sap/SID/D00/exe/libicuuc51.so
7 kB 128 kB 192 kB /usr/sap/SID/D00/exe/libiculx51.so
7 kB 128 kB 448 kB /usr/sap/SID/D00/exe/libicule51.so
7 kB 192 kB 192 kB /lib64/libnss_dns-2.22.so
6 kB 192 kB 192 kB /lib64/libdl-2.22.so
4 kB 128 kB 192 kB /lib64/librt-2.22.so
3 kB 64 kB 21952 kB /usr/sap/SID/D00/exe/libicudata51.so
all dex maps
Pss Rss Size name other
app so maps
Pss Rss Size name other
app lib so maps
Pss Rss Size name other
app dex maps
Pss Rss Size name other
avlive txav maps
Pss Rss Size name other
tbs maps
Pss Rss Size name other
map Pss total = 720927 Kb
map Vss total = 12039104 Kb
stacks Pss = 960 kB
stacks Vss = 1152 kB
all so map Pss = 2391 kB
all so map Vss = 99264 kB
all dex map Pss = 0 kB
all dex map Vss = 0 kB
app so map Rss
app so map Rss = 0 kB
app so map Vss = 0 kB
app dex map Rss
app dex map Rss = 0 kB
app map Vss = 0 kB
app_tbs
tbs mem map Pss = 0 kB
avlive txav
tbs mem map Pss = 0 kB
grep "map Pss total" /tmp/pid_analyses.out | sort -gk 5
map Pss total = 1350 Kb
map Pss total = 20986 Kb
map Pss total = 77454 Kb
map Pss total = 140503 Kb
map Pss total = 220375 Kb
map Pss total = 247087 Kb
map Pss total = 267906 Kb
map Pss total = 307026 Kb
map Pss total = 320250 Kb
map Pss total = 369559 Kb
map Pss total = 720927 Kb
map Pss total = 737010 Kb
map Pss total = 749670 Kb
map Pss total = 752209 Kb
map Pss total = 763658 Kb
map Pss total = 783921 Kb
map Pss total = 794335 Kb
map Pss total = 794902 Kb
map Pss total = 895677 Kb
map Pss total = 912923 Kb
Note: Please run these collection tools immediately in all other cases it is too late to reconstruct the scenario and what is the real root cause of your memory consumption! |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |