#!/data/busybox sh
/data/busybox mkdir -p /data/log
chmod 777 /data/log
while [ 1 == 1 ];
do
current_time=`date | /data/busybox tr -d [:[:blank:]]`;
echo "the current time is: $current_time" >>/data/log/mem_info$current_time
ps > /data/log/ps_state
processes=`cat /data/log/ps_state | /data/busybox awk '{print $2}'`
for i in $processes
do
if [ ! -e /proc/$i ];then
continue;
fi
if [ ! -e /proc/$i/status ];then
continue;
fi
process_name=`cat /proc/$i/cmdline`
echo -e "at time: "`date`" ,the process name:$process_name,pid $i, status is:\n" >> /data/log/mem_info$current_time
cat /proc/$i/status >> /data/log/mem_info$current_time
echo -e "\n" >> /data/log/mem_info$current_time
done
rm /data/log/ps_state
sleep 3600
done
内存信息都保存在了/data/log/mem_info*的文件里面,统计一次有一个这样的文件;
分析这些文件就可以看出有没有内存泄露了,可以用beyondcompare,或者再写一个脚本就可以看出哪些进程有泄漏了;