Memory leak
Also called: Leak
Memory that a program no longer needs but can't free, because something still refers to it.
Definition
In languages with ARC or a garbage collector, leaks aren't forgotten free() calls; they are references nobody remembered: a retain cycle under ARC, or an object still reachable from something long-lived, such as a singleton's listener list, a static cache or a running timer. Leaked screens keep their whole view tree in memory, so memory grows every time the user opens them, until the system kills the app.
In practice
A screen registers a listener with an app-wide download manager and never removes it, so every closed screen stays in memory.
Related terms
- Retain cycleTwo or more objects holding strong references to each other, so none of them is ever freed.
- Garbage collectionThe runtime periodically finds objects nothing can reach any more and frees them for you.
- Weak referenceA reference that lets you reach an object without keeping it alive; it becomes empty once the object is freed.