This document discusses memory leaks in Android applications. It defines a memory leak as when objects are created but not deleted from memory even when they are no longer needed. It recommends using the Android Monitor tool to detect leaks by monitoring heap usage over time. Potential causes of leaks discussed include holding static references to activities or views, inner classes that outlive their outer class, anonymous classes, RxJava, and failing to unregister system service listeners. Methods for detecting and preventing leaks include using the Android Monitor, Heap Viewer, and Memory Analyzer tools, ensuring references are cleared properly, and using weak/soft references when appropriate.
41. 2. INNER CLASSES
▸ don’t make non-static inner classes
that may live longer than Activity
▸ don’t keep reference to Activity by
something that may live longer than
Activity
▸ try to replace non-static inner class with
static inner class