adb Shell Dumpsys command to view memory

Source: Internet
Author: User

http://blog.csdn.net/xyz_lmn/article/details/7001892Android program memory is divided into 2 parts: native and Dalvik,dalvik are the Java heaps we normally call, the objects we create are assigned here, and bitmap are allocated directly on native, and the limit for memory is native+ Dalvik cannot exceed the maximum limit. Android program memory is generally limited to 16M, of course, there are 24M. use the following command to view the memory usage of the program:adb shell Dumpsys meminfo $package _name or $pid//Use the program's package name or process IDuse Com.tencent.qqpimsecure as an example:

    具体每一项代表什么,参考:http://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-android#2299813,我们比较关心的是这2行:

Where size is the required memory, and allocated is allocated memory, the corresponding 2 columns are native and Dalvik, and when the total is the maximum limit of the individual program memory, Oom is likely to occur.

Most of the time, the occurrence of Oom is doing some picture-related operations, the following suggestions to minimize the occurrence of this situation:

1.decode bitmap 的时候,尽量配置下Options,例如:inSameSize
2.Bitmap使用完以后,调用 bitmap.recycle()来释放内存
3.如果应用是基于图片的应用,尽量采用LazyLoad和DymanicRecycle
4.decode bitmap 的时候,将decode代码 trycatch 出来,catchoom error,避免程序crash,可以在catch里面做一些释放内存操作

http://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-android/2299813#2299813

/**
* @author Zhang Xingye
* Email: xy-zhang#163.com
* Android Development Advanced Group:278401545
*
*/

adb Shell Dumpsys command to view memory

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.