Camera-memory内存泄漏分析(二)

        通过Provider对com.android.camera2进行memory监控仅仅相当于对某一进程的memory info信息监控,当真正发生内存泄漏的情况下,单独check camera.android.camera2单独的包肯定是不能完全的check问题点的,可以通过sysinfo所对应的/proc/meminfo信息里面的MemAvailable 显示的大小进行宏观的使用情况查看,进而对怀疑的进程通过dumpsys meminfo的方式去check具体的怀疑进程,现在以Camera模块为例进行问题说明。

一、sysinfo信息确定问题时间节点

        每2min打印系统meminfo 的sysinfo log,在相关问题发生的时间节点前后可以通过sysinfo的大致时间点初步确定一下meminfo的状态是否有问题。

具体追踪log如下: 

        先看是否有crash等造成camera崩溃的log产生

        分析sysinfo相关的memAvailable,每2min之内有200M左右的memory信息波动,在一个2min的波段之内发生了800M的内存波动,这边的异常发生会导致camera crash等相关信息进而释放掉占用的内存导致大的内存变化波动。

        22:52:25-22:54:26之间分析其他的main log对应的节点发现 com.android.camera OOM异常(类似报错:lowmemory)的报错信息。

二、通过dumpsys meminfo 压测定位相关进程的内存占用

        对camera相关的各个进程的memory使用情况进行监控以及处理。                  1.

        1.通过命令dump camera应用层相关的memory

        adb shell "dumpsys meminfo com.android.camera2 | awk '/Graphics|Java Heap:|Native Heap:|TOTAL PSS/' " >>meminfo.txt

        2.通过命令dump camera HAL/FrameWork层相关的memory信息

        adb shell ps -A | grep camera

        查看camera HAL相关的内存信息

        adb shell "dumpsys meminfo 504" >> meminfo_cameraprovider.txt 

        查看camera FrameWork层相关的内存信息
        adb shell "dumpsys meminfo 726" >> meminfo_cameraserver.txt

        最后对每次测试所拿到的memory Total Pss信息进行统计,绘制成相关进程连连续拍照占用memory相关的图表即可直观的观察到相关的内存消耗情况,视图如下:

        

      

展讯平台 Camera相关进程

MTK平台 Camera相关进程

总结 

        内存相关的异常处理起来肯定不像其他问题一样简单,需要反复的压测,确定具体的异常点,甚至需要借用addr2line -e -f 解析动态链接库,定位异常发生时的堆栈地址对应的函数接口;objdump -S -D反汇编相关的lib,确定具体的问题点; 最后如果能定位到具体的某一个内存申请的点,解决起来就会好很多。

Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems. This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25. 输入说明 The input will consist of a set of pairs of values for R and n. The R value will occupy columns 1 through 6, and the n value will be in columns 8 and 9. 输出说明 The output will consist of one line for each line of input giving the exact value of R^n. Leading zeros should be suppressed in the output. Insignificant trailing zeros must not be printed. Don't print the decimal point if the result is an integer. 输入样例 95.123 12 0.4321 20 5.1234 15 6.7592 9 98.999 10 1.0100 12 输出样例 548815620517731830194541.899025343415715973535967221869852721 .00000005148554641076956121994511276767154838481760200726351203835429763013462401 43992025569.928573701266488041146654993318703707511666295476720493953024 29448126.764121021618164430206909037173276672 90429072743629540498.107596019456651774561044010001 1.126825030131969720661201 小提示 If you don't know how to determine wheather encounted the end of input: s is a string and n is an integer C++ while(cin>>s>>n) { ... } c while(scanf("%s%d",s,&n)==2) //to see if the scanf read in as many items as you want /*while(scanf(%s%d",s,&n)!=EOF) //this also work */ { ... } 来源 East Central North America 1988 北大OJ平台(代理
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值