memory leak

Memory that a program keeps holding although it no longer needs it, so usage grows until the program slows down or crashes.

In more detail

Common causes are timers, listeners and caches that are never cleaned up, and references kept to objects that are no longer needed. A garbage collector cannot free anything that is still referenced, so leaks happen even in languages with automatic memory management.

Examples

Typical browser leaks: forgotten intervals, listeners and MutationObservers never removed, and detached DOM trees kept in variables. WeakMap, AbortSignal and disconnect() help avoid them.
In React apps leaks usually come from listeners, timers or subscriptions set up in an Effect without a cleanup function.

Related terms

Taught in

References