Effective Kotlin: Item 7 — Eliminate obsolete object references

On Android, accidentally holding onto a reference such as to the Activity leads to out of memory crashes that can be hard to find showing the importance of item 7 of Joshua Bloch’s excellent book Effective Java.

One of the easiest ways to leak an activity on Android is with inner classes, especially the Handler class. How to Leak a Context talks about this in a lot more detail as does AlertDialog causes a memory leak.

A less visible place memory leaks can occur is when using Butterknife in…