Memory & Performance

5 concepts · 10 practice questions

Memory leaks

A leak is an object that is no longer needed but is still reachable from a GC root. On Android the classic one is a long-lived object, such as a singleton, static field, or running task, holding an Activity, View, or Fragment. LeakCanary finds them by watching destroyed objects.

object Analytics {
    lateinit var context: Context   // pass applicationContext, never an Activity
}

Also covered

Garbage collection on ART
Bitmaps
Jank and the main thread
Startup performance

Sign in to read the rest and take the 10-question test.

Sign in to continue