官网
GitHub - square/leakcanary: A memory leak detection library for Android.
LeakCanary
项目简介
LeakCanary’s knowledge of the internals of the Android Framework gives it a unique ability to narrow down the cause of each leak, helping developers dramatically reduce Application Not Responding freezes and OutOfMemoryError crashes.
Getting started¶
To use LeakCanary, add the leakcanary-android dependency to your app’s build.gradle file:
dependencies {
// debugImplementation because LeakCanary should only run in debug builds.
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
}
That’s it, there is no code change needed!
Confirm that LeakCanary is running on startup by filtering on the LeakCanary tag in Logcat:
D LeakCanary: LeakCanary is running and ready to detect leaks