Android/OutOfMemory対策/leakcanary
提供: 初心者エンジニアの簡易メモ
2020年9月18日 (金) 10:56時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「==leakcanaryを導入して調査== 公式:https://github.com/square/leakcanary ==導入方法== ver1と2がある。 何が違うかは、こちらを。https://squa...」)
leakcanaryを導入して調査
公式:https://github.com/square/leakcanary
導入方法
ver1と2がある。
何が違うかは、こちらを。https://square.github.io/leakcanary/upgrading-to-leakcanary-2.0/
ver1
app/build.gradle
dependencies {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
// Optional, if you use support library fragments:
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
}
ExampleApplication.java
public class ExampleApplication extends Application {
@Override public void onCreate() {
super.onCreate();
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);
// Normal app init code...
}
}
ver2
app/build.gradle
dependencies {
implementation 'com.squareup.leakcanary:leakcanary-object-watcher-android:2.4'
}
