Memory Leaks & Performance Considerations: A Cookbook
summary
Android apps leak memory when background work outlives UI lifecycles; coroutines can leak too unless using structured concurrency and cancelable scopes. Practical fixes include using LeakCanary and Android Profiler, nulling view references (e.g. call MapView.destroy), avoiding static Contexts, and preferring coroutine scopes with a CoroutineExceptionHandler or SupervisorJob. AsyncTask (deprecated 2019) and improperly bound services commonly cause leaks. Kotlin bug KT-1622 is fixed in Kotlin 1.4, and the O’Reilly book "Programming Android with Kotlin: Achieving Structured Concurrency with Coroutines" documents patterns.
AI-written summary · about
chapters (14)
- 0:00Introduction to memory leaks
- 1:53History of memory leaks
- 3:38Memory leaks in Android
- 5:45Why memory leaks matter
- 7:31Self-managed memory environment
- 10:44Explicit vs implicit leaks
- 12:30AsyncTask and memory leaks
- 16:20Implicit leaks in coroutines
- 17:23Thread pool executors
- 20:51Thread cancellation issues
- 23:58Coroutine exception handling
- 26:46Leak Canary demonstration
- 30:01Key lessons and best practices
- 32:51Summary and resources
related talks
28mMemory Leaks & Performance Considerations: A Cookbook
42mSpeaking of Leaking
25mMemory leaks on Android: lessons learned and methodology
24mUnveiling the Unseen Threat: Demystifying Memory Leaks in Android
53mMemory on Android, Leaks and OOM
38mKotlin High-Performance Programming
07mAndroid memory tools and best practices
29m10 Ways To Improve Your Android App Performance
