「Android/OutOfMemory対策/leakcanary」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==leakcanaryを導入して調査== 公式:https://github.com/square/leakcanary ==導入方法== ver1と2がある。 何が違うかは、こちらを。https://squa...」) |
|||
| 行41: | 行41: | ||
} | } | ||
</pre> | </pre> | ||
| + | |||
| + | ==使い方== | ||
| + | メモリリークが起こると、自動で検知&解析してくれる。 | ||
| + | ==参考== | ||
| + | https://mokumokulog.netlify.app/tech/20171112160128 | ||
2020年9月18日 (金) 11:00時点における版
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'
}
使い方
メモリリークが起こると、自動で検知&解析してくれる。
