Skip to main content
PreparationZone Logo
PreparationZone
Back to Fundamentals

Fundamentals · Medium · Free

What is a memory leak? How do GC languages still leak memory?

FresherFundamentalsOOP & Language Fundamentals
Model answer

Memory leaks

A leak is memory no longer needed but still reachable—GC cannot collect it. In GC languages: static collections, listeners not removed, unclosed streams, ThreadLocal abuse.

  • C/C++: missing free / RAII with smart pointers.
  • Java: cache grows forever—use size bounds or weak references.
  • Profile with heap dumps / VisualVM when OOM in prod.
Show maturity: leaks are about reachability, not missing delete in Java.