1、根据进程号(pid),获取进程的内存占用情况
adb shell
dumpsys meminfo 53278
2、根据类名,获得对应的进程号
ps -ef | grep com.huawei.multimedia.audioengine.HwAudioKaraokeFeatureService
(包含grep查询进程名)
ps -ef | grep com.huawei.multimedia.audioengine.HwAudioKaraokeFeatureService | grep -v grep
(忽略grep查询进程名)
ps -ef | grep com.huawei.multimedia.audioengine.HwAudioKaraokeFeatureService | grep -v grep | awk '{print $2}'
(获得该进程的pid)
3、根据查询到的进程号,查询内存占用情况
adb shell
dumpsys meminfo $(ps -ef | grep com.huawei.multimedia.audioengine.HwAudioKaraokeFeatureService | grep -v grep | awk '{print $2}')
4、使用watch,自动周期性执行
watch -n 1 dumpsys meminfo $(ps -ef | grep com.huawei.multimedia.audioengine.HwAudioKaraokeFeatureService | grep -v grep | awk '{print $2}')
(1秒执行1次)
5、将结果同时显示在屏幕和文件中
watch -n 1 dumpsys meminfo $(ps -ef | grep com.huawei.multimedia.audioengine.HwAudioKaraokeFeatureService | grep -v grep | awk '{print $2}') | tee -a zkaiMem.txt
(-a追加写)
【上面的不显示在屏幕上】
watch -n 1 dumpsys meminfo $(ps -ef | grep com.huawei.multimedia.audioengine.HwAudioKaraokeFeatureService | grep -v grep | awk '{print $2}') | tee -a zkaiMem.txt | cat -v
6、上述的结果显示存放在手机中,将其pull到手机上来
adb pull /sdcard/zhangkai/zkaiMem.txt
网友评论