内存统计
#!/bin/sh if [ -z "$1" ]; then modlist="ServiceManager DSVMCUCOMSVC DSVSystemSVC DSVProxySVC Lifecycle AppManager DSVConfigSVC NadService Loc_Service DSVAudioSVC DSVUpdateSVC DSVNetworkSVC DSVOBOXAdaptorSVC DSVOBOXSDKSVC DSVICICOMSVC DSVVTMAdaptorAPP DSVCallAPP DSVVehicleCOMAPP DSVICICOMAPP DSVLocationAPP DSVDiagnosticAPP DSVUpdateAPP DSVEngineeringModeAPP" else modlist=$1 fi for j in $modlist do pid=`ps aux | grep $j |head -n 1|cut -d ' ' -f 2` echo "------------------------" echo -n `cat /proc/$pid/status | head -n 1` echo "[$pid]" echo "------------------------" cat /proc/$pid/smaps | awk '/Size|Rss|Pss/{val_name=gensub(/([a-zA-Z_]*).*/,"\\1",1,$1); list[val_name]+=$2; }END{for(val in list)print val,list[val];}' done exit 0
使用脚本计算每个进程的内存消耗
Pss:物理内存 – 实际使用的内存
Rss:驻留内存
使用方法:
#./getmem.sh
列举当前所有我们自己的app/service每个进程占据的内存容量
#./getmem.sh pid
列举某进程pid的进程占据内存容量