ADB shell dumpsys command to view memory

Source: Internet
Author: User
The memory of the android program is divided into two parts: Native and Dalvik. Dalvik is the Java heap we usually call. The objects we create are allocated here, bitmap is directly allocated on native. The memory limit is that native + Dalvik cannot exceed the maximum limit. The memory size of Android programs is generally limited to 16 MB, of course there are also 24 MB. Run the following command to view the memory usage of the program: ADB shell dumpsys meminfo $ package_name or $ PID // use the package name or process ID of the program as an example:
For details about what each item represents, refer:

 
The size is the required memory, and the allocated is the allocated memory. The corresponding two columns are native and Dalvik, respectively, oom may occur when the total number, that is, the total column, exceeds the maximum memory limit of a single program.
Most of the time, oom operations are related to images. The following are some suggestions to minimize this situation: 1 . Decode bitmap, configure options as much as possible, for example, insamplesize; 2After using bitmap, call
Bitmap. Recycle () to release memory;

3If the application is an image-based application, use lazyload and dymanicrecycle as much as possible;
4. Decode
When bitmap is used, decode
try catch Come out,catch OOM
To avoid program crash, you can
catchTo release the memory;

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

Article transferred from: http://blog.csdn.net/xyz_lmn/article/details/7001892
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.