美文网首页
如何抓取系统memory使用状况

如何抓取系统memory使用状况

作者: RTThread小师弟 | 来源:发表于2017-10-31 19:33 被阅读0次

    当出现系统memory不足导致高优先级进程被kill等异常时,需要抓取一段时间内的

    memory使用情况.

    一. 在使用Mali GPU平台上(MT6572 MT6582 MT6592)使用如下脚本抓取.

    具体测试手法如下:

    1. 先将手机时间设置成和PC一样,清除mtklog,开启mobilelog.

    2. 双击此脚本。

    3. 出现问题后,停止脚本(Ctrl+C)将mobilelog和D:\MemLog一起打包

    脚本内容:

    @echo off

    set logpath1=D:\MemLog\procrank.txt

    set logpath2=D:\MemLog\GPU_memory_usage.txt

    set logpath4=D:\MemLog\meminfo.txt

    set logpath5=D:\MemLog\librank.txt

    set logdir= D:\MemLog

    del %logdir%

    :loop

    echo %date% %time%

    echo %date% %time% >> %logpath1%

    adb shell procrank -u >> %logpath1%

    echo %date% %time% >> %logpath2%

    adb shell cat /proc/mali/memory_usage >> %logpath2%

    echo %date% %time% >> %logpath4%

    adb shell cat proc/meminfo >> %logpath4%

    echo %date% %time% >> %logpath5%

    adb shell librank >> %logpath5%

    echo "wait 5s to next catch"

    ping -n 5 127.0.0.1>nul

    goto loop

    二. 在非Mali GPU平台上使用如下脚本:

    @echo off

    set logpath1=D:\MemLog\procrank.txt

    set logpath4=D:\MemLog\meminfo.txt

    set logdir= D:\MemLog

    del %logdir%

    :loop

    echo %date% %time%

    echo %date% %time% >> %logpath1%

    adb shell procrank -u >> %logpath1%

    echo %date% %time% >> %logpath4%

    adb shell cat proc/meminfo >> %logpath4%

    echo "wait 5s to next catch"

    ping -n 5 127.0.0.1>nul

    goto loop

    三. 当确认是某个AP进程占用memory多,需要再监控对应进程时.

    在Mali GPU平台使用如下脚本。

    双击后输入对应进程的PID后开始抓取

    @echo "please input the target pid :"

    @echo off

    adb shell ps

    set processid=

    set /p processid=Please Input process id to catch:

    @echo off

    set logpath1=D:\MemLog\procrank.txt

    set logpath2=D:\MemLog\GPU_memory_usage.txt

    set logpath3=D:\MemLog\Mem-%processid%.txt

    set logpath4=D:\MemLog\meminfo.txt

    set logpath5=D:\MemLog\librank.txt

    set logdir= D:\MemLog

    del %logdir%

    :loop

    echo %date% %time%

    echo %date% %time% >> %logpath1%

    adb shell procrank -u >> %logpath1%

    echo %date% %time% >> %logpath2%

    adb shell cat /proc/mali/memory_usage >> %logpath2%

    echo %date% %time% >> %logpath3%

    adb shell dumpsys meminfo %processid% >> %logpath3%

    echo %date% %time% >> %logpath4%

    adb shell cat proc/meminfo >> %logpath4%

    echo %date% %time% >> %logpath5%

    adb shell librank >> %logpath5%

    echo "wait 5s to next catch"

    ping -n 5 127.0.0.1>nul

    goto loop

    四. 当确认是某个AP进程占用memory多时,需要再监控对应进程时.

    在非Mali GPU平台使用如下脚本。

    双击后输入对应进程的PID后开始抓取

    @echo "please input the target pid :"

    @echo off

    adb shell ps

    set processid=

    set /p processid=Please Input process id to catch:

    @echo off

    set logpath1=D:\MemLog\procrank.txt

    set logpath3=D:\MemLog\Mem-%processid%.txt

    set logpath4=D:\MemLog\meminfo.txt

    set logdir= D:\MemLog

    del %logdir%

    :loop

    echo %date% %time%

    echo %date% %time% >> %logpath1%

    adb shell procrank -u >> %logpath1%

    echo %date% %time% >> %logpath3%

    adb shell dumpsys meminfo %processid% >> %logpath3%

    echo %date% %time% >> %logpath4%

    adb shell cat proc/meminfo >> %logpath4%

    echo "wait 5s to next catch"

    ping -n 5 127.0.0.1>nul

    goto loop

    原文:http://bbs.16rd.com/thread-54279-1-148.html

    相关文章

      网友评论

          本文标题:如何抓取系统memory使用状况

          本文链接:https://www.haomeiwen.com/subject/xoqipxtx.html