Android Memory leak tool Leakcanary use

Source: Internet
Author: User

Han Mengfei sha yue31313 Han Yafei Han_meng_fei_sha [email protected]

Leakcanary is square open source A memory leak automatic detection artifact. This is the project's GitHub warehouse address: Https://github.com/square/leakcanary. It is very easy to use a package dependency in Build.gradle:

dependencies {   ' com.squareup.leakcanary:leakcanary-android:1.5'    com.squareup.leakcanary:leakcanary-android-no-op:1.5' com.squareup.leakcanary:leakcanary-android-no-op:1.5 '}    

Add initialization code to the OnCreate method in application:

if (leakcanary.isinanalyzerprocess (this)) {
This process was dedicated to leakcanary for
Heap analysis.
You should the NOT init your app on this process.
return;
}
Leakcanary.install (this);

After the integration of nothing to do, according to normal testing, when a memory leak occurs, the application will be notified through the system notification bar, click on the notification can be entered to view the details of the memory leak. Here is an example of a practice. After the leakcanary is integrated into the project, and so on after the app launches, the system notifies, clicks the notification, jumps to the leaked details page to view.

Android Memory leak tool Leakcanary use

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.