美文网首页
LeakCanary内存泄漏检测

LeakCanary内存泄漏检测

作者: 0dce86ba3565 | 来源:发表于2017-09-22 18:26 被阅读0次

1.在build.gradle中加入引用,不同的编译使用不同的引用:

dependencies {

            debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'

            releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'

}

2.修改application类: 

3.检测fragment

public abstract class BaseFragment extends Fragment{

     @Override

     public void onDestroy(){

              super.onDestroy();

              RefWatcherrefWatcher=ExampleApplication.getRefWatcher(getActivity());

              refWatcher.watch(this);

      }

}

相关文章

网友评论

      本文标题:LeakCanary内存泄漏检测

      本文链接:https://www.haomeiwen.com/subject/wggfextx.html