51Testing软件测试论坛
标题:
引入LeakCanary监听内存泄漏
[打印本页]
作者:
感悟时分
时间:
2019-3-15 13:45
标题:
引入LeakCanary监听内存泄漏
debugCompile ‘com.squareup.leakcanary:leakcanary-android:1.5.4’
releaseCompile ‘com.squareup.leakcanary:leakcanary-android-no-op:1.5.4’二在application里添加public class TestApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
initLeakCanary();
}
private RefWatcher mRefWatcher;
private void initLeakCanary() {
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
mRefWatcher = RefWatcher.DISABLED;
return;
}
mRefWatcher = LeakCanary.install(this);
}
}
复制代码
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2