LeakCanary 内存溢出检测工具

来源:互联网 发布:淘宝助理违规验证通过 编辑:程序博客网 时间:2024/05/17 09:11

https://github.com/square/leakcanary



使用方法

 第一步:

 gradle文件中配置

 dependencies {   debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'   releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'   testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' }
第二部
在application中添加初始化,然后就可以直接运行App了,然后如果有内存溢出,就会有显示消息
if (LeakCanary.isInAnalyzerProcess(this)) {      // This process is dedicated to LeakCanary for heap analysis.      // You should not init your app in this process.      return;    }    LeakCanary.install(this);

0 0