⚙️Memory Leak
Also known as Memory Leaks, Leaking Memory
Memory a program still holds but does not need now.
Think of it like
Think of it like a tap left dripping into a sink. Slowly the sink fills and spills over.
Example
Jack's server adds every request to a global list for debugging and never clears it. It uses 200 MB on Monday and 4 GB by Friday, then crashes.
Why it matters
Leaks hide in testing, because tests are short. They show up days later in production as slow pages and crashes.
Definition
Example code
javascript
const seen = [];
app.get('/', (req, res) => {
seen.push(req); // never removed: the list grows forever
res.send('ok');
});Common mistake
Key takeaways
- 1Kept, not needed. Memory never returned.
- 2Grows over time. Slow, then a crash.
- 3Any language. Even with garbage collection.