What Is a Memory Leak?
A memory leak happens when a program keeps allocating memory it no longer needs without releasing it, causing memory usage to grow continuously over time.
Published October 7, 2026
A memory leak happens when a program keeps allocating memory it no longer needs without releasing it, causing memory usage to grow continuously over time.
Why it exists
- In manually managed languages, this happens when allocated memory is never explicitly freed
- In garbage-collected languages, this happens when something unintentionally keeps a reference alive to an object that's no longer actually needed, preventing it from being collected
How to apply it
- Watch for common culprits: event listeners never removed, ever-growing caches with no eviction policy, and closures unintentionally capturing large objects
- Use memory profiling tools (heap snapshots) to identify what's actually accumulating when memory usage grows unexpectedly
FAQ
How do I know if my application has a memory leak?
The clearest sign is memory usage that climbs steadily over time under normal, repeated usage and never comes back down, even after garbage collection runs.