What is a Memory Leak?

Definition

A memory leak happens when memory that is no longer needed is still referenced, so the garbage collector cannot free it. In React this usually means a component is gone (unmounted) but something it started is still running: a timer, an event listener, a subscription or a request.

  • The app gets slower over time.
  • Memory usage keeps growing (DevTools → Memory).
  • Old callbacks still run and update state that no longer exists.