Definition

Memory Leak

A memory leak is a software defect where an application progressively consumes more memory over time because it allocates memory for operations but fails to release it when it is no longer needed, eventually degrading performance or causing crashes.

Understanding Memory Leak

Memory leaks are insidious because they do not cause immediate failure. The application starts working fine, but over time it slows down, becomes unresponsive, and may eventually crash. Users who keep a web application open in a browser tab for hours, or who navigate through many pages in a single session, are most likely to encounter the effects of memory leaks.

In web applications, common causes of memory leaks include event listeners that are never removed, intervals or timeouts that are never cleared, references to DOM elements that have been removed from the page, and growing data structures that are never pruned. AI-generated code frequently creates these situations because the AI focuses on making features work without always implementing proper cleanup logic.

Memory leaks can be difficult to catch in short testing sessions because the effects accumulate gradually. Testers who spend extended time exploring an application or who navigate through many different pages in a single session are more likely to notice the telltale signs: increasing sluggishness, rising browser memory usage, and eventual unresponsiveness.

Related terms

Learn more