NOTE

Memory Leaks in Garbage-Collected Programs

How reachable-but-unneeded objects, native allocations, caches, queues, callbacks, and threads create memory leaks despite GC.

Garbage Collection / RuntimeUpdated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

Garbage collection reclaims unreachable memory. An application can still leak memory by keeping references to objects it no longer logically needs.

Common causes include unbounded caches/maps/queues, listeners not removed, thread-local values on long-lived threads, class-loader retention, forgotten request/session state, and background tasks retaining large object graphs.

Process memory can also grow outside the managed heap through direct/native buffers, thread stacks, native libraries, and allocators.

Diagnose with retained-object/heap analysis for managed leaks and process/native-memory evidence when heap usage does not explain RSS growth.

Loading helpful count