Heads upThis post was last updated 1 year ago.Some details may be out of date. Double-check against current practices.
In the process of developing Android applications, developers inevitably encounter Memory Leaks. This article aims to provide knowledge and experience in finding Leaks as quickly as possible through the Android Profiler and Leaks Canary tools.
Android Studio Profiler to Observe Memory and Detect Leaks
Open the Profiler tool from Android Studio: View / Tool Windows / Profiler
Select the app to Monitor
Observe the Memory and CPU screen
Snap Memory to observe Leaks
Leak Canary to Observe and Detect Leaks
Add dependency
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
Reproduce the Leak and wait for Heapdumps