Leakcanary: Simple and crude memory leak detection Tool

Source: Internet
Author: User

Almost every programmer encounters a memory leak in the process of development, so how do we detect where the app is going to have a memory leak? Square has unveiled a simple and crude tool for detecting memory leaks-leakcanary

What is a memory leak?

Memory leak refers to the failure of the program to release the memory that is no longer in use because of negligence or error, and the memory leak is not the physical disappearance of the internal, but the application allocates some memory, because the design error loses the control of this memory, resulting in a waste of memory.

Memory leaks and memory overflow is not the same thing, do not confuse, memory overflow popular is memory is not enough, now only mobile memory is more and more large, memory overflow situation is not many, but the memory leak situation is more serious, the arrival of Leakcanary for us is a simple rough, intuitive good tool


The above image is the icon of this tool, when your program is in debug mode, you can see him, of course, release no


Leakcanary as a simple and crude tool, the usage is quite simple.

Introduction of Leakcanary in Build.gradle

Debugcompile ' com.squareup.leakcanary:leakcanary-android:1.3 '    releasecompile ' com.squareup.leakcanary: leakcanary-android-no-op:1.3 '


One is the debug package, one is the release package, from the introduction of the structure of the package can also see the clues

Since leakcanary is testing the memory leak of the entire app, you need to start it in your application

Package Com.zimo.guo;import android.app.application;import com.squareup.leakcanary.leakcanary;/** * Created by Zimo on 15/8/7. */public class MyApplication extends application {    @Override public    void OnCreate () {        super.oncreate ();        Leakcanary.install (this);}    }

OK, now you can test the memory leaks in the program, intuitive


So have the tool, hurry to try it, want to make your app's memory leaks, try it

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Leakcanary: Simple and crude memory leak detection Tool

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.