"Android" Development optimization--view memory situation, find memory leaks

Source: Internet
Author: User

Although you know the general development of Android applications need to pay attention to the problem, but there are uneven levels of the situation, especially maintenance code, if memory consumption, memory overflow serious, how to solve it? --by Ddms the heap out to analyze


1. Open Ddms


2. Select the program you want to view, and click the Update heap icon



3. View the heap situation



But this is just a look at the usage of the heap, and if memory usage or overflow is found to be very serious, it will be oom. Through this is not see anything, this time need to take out the heap analysis, there is a button on the edge of the updateheap.


Click, will generate a file, save it (a little delay, patience, etc. oh, I saved to the desktop)


7. View the file you just downloaded, but to view before we need MAT



8, install the mat, the steps are basically on-line, the method is: eclipse-"help-" Eclipse marketplace-"Select memory analysis to the right of the install and then next step installation."


9.. hprof file conversion, files saved directly by DDMS cannot be viewed with mat and will be incorrectly formatted. This is the time to use the SDK with the tool Hprof-conv to convert.


C:\users\administrator>hprof-conv C:\Users\Administrator\Desktop\test.hprof C:\Users\Administrator\Desktop\ Hprofed-test.phrof


10. Use the mat to open the. hprof file to view memory usage.



As for the mat how to use Baidu or Google is still a lot of, or so I research to the value of Android, I will open a post to explain!



"Android" Development optimization--view memory situation, find memory leaks

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.