为何android 2.x上,DDMS显示使用的内存较小
来源:互联网 发布:软件设计师任职资格 编辑:程序博客网 时间:2024/04/29 22:31
http://stackoverflow.com/questions/13834060/troubleshooting-android-app-memory-usage-problems
重点描述:
Note that if you ran this on Android 1.x/2.x, MAT will not report space consumed by bitmaps. Always try to dump the heap from an Android 3.0+ device or emulator.
Troubleshooting android app memory usage problems
I would like to know how I can troubleshoot high memory usage problems of my app on Android. I've search the internet and found out that the DDMS plugin is useful in taking a memory dump of the heap for my app. This however has been useless.
The app "Usage Timelines Free" is showing 94 MBs of memory used, while the DDMS heap dump shows me a total of 8.4 MBs, with the suspected leaks being the resource files.
When I generate a dump from adb (dumpsys meminfo), I get:
Shared Private Heap Heap Heap Pss Dirty Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ Native 20 8 20 54588 39431 1892 Dalvik 6732 9952 6396 10756 10028 728 Cursor 0 0 0 Ashmem 184 0 184 Other dev 11462 1172 11384 .so mmap 2467 2072 1156 .jar mmap 0 0 0 .apk mmap 48 0 0 .ttf mmap 2 0 0 .dex mmap 1037 0 0
Other mmap 41 16 32
Unknown 46352 292 46348 TOTAL 68345 13512 65520 65344 49459 2620
How can I know what is behind this huge memory consumption. My app is a foreground monitor service which runs forever, with a few activities which are accessed a few times per day.
Thanks.
1 Answer
DDMS and got a heap memory dump. It only showed 8.4 MBs being used!
Then you are only using 8.4MB of heap space after a complete garbage collection (a net effect of creating the heap dump).
Note that if you ran this on Android 1.x/2.x, MAT will not report space consumed by bitmaps. Always try to dump the heap from an Android 3.0+ device or emulator.
When I generate a dump from adb (dumpsys meminfo), I get:
My guess is that you are running this on an Android 1.x/2.x device or emulator, and you have a lot of bitmap memory. Try running your heap dump and other tests on an Android 3.0+ environment.
Also, bear in mind that adb dumpsys meminfo
does not perform a complete garbage collection, whereas dumping the HPROF file does. The Android garbage collector is optimized to minimize CPU utilization and therefore does not attempt to perform a complete garbage collection. Hence, at runtime, the heap is usually filled with garbage that will be reclaimed, as needed, by the GC engine.
You might also wish to read Dianne Hackborn's essay on this subject.
- 为何android 2.x上,DDMS显示使用的内存较小
- DDMS的使用、内存溢出的调试
- android 内存管理工具 DDMS
- Android开发中使用eclipse中的DDMS对应用的内存检测
- Android 调试工具 DDMS的使用
- android调试工具DDMS的使用详解
- android调试工具DDMS的使用详解
- Android Studio之DDMS的使用
- android调试工具DDMS的使用详解
- Android开发:使用DDMS Heap进行内存泄露调试
- Android内存分析工具DDMS heap + MAT 安装和使用
- Android开发:使用DDMS Heap进行内存泄露调试
- Android开发:使用DDMS Heap进行内存泄露调试
- Android内存分析工具DDMS heap + MAT 安装和使用
- 【测试工具】Android内存检测工具DDMS安装及使用
- 使用DDMS中的native heap检查Android native内存泄露
- android 内存监测工具 DDMS 和mat 工具使用
- Android DDMS如何使用
- 多PC公用一套鼠标键盘
- 在Fedora 16上安装Nginx(带PHP-FPM)+PHP5和MySQL支持 fix bug确保能用
- iPhone5判断
- 【Android】App自适应draw9patch不失真背景
- uva 193 - Graph Coloring
- 为何android 2.x上,DDMS显示使用的内存较小
- 《企业应用架构模式》学习笔记(一)
- 高斯与老师七个 0 的故事之程序
- 进程内存分布
- 细数 javascript 容易被忽略的语法陷阱
- repo的小结
- VI常用命令
- c# 生成文字图片
- Teechart 官方教材