0
Explain a suspected memory leak from heap snapshots and propose a fix
I suspect a memory leak in service_name (language/runtime). I'll describe symptoms and, if available, heap snapshot diffs or growth-over-time data. Help me:
1. Distinguish a true leak (unbounded growth, objects that should be freed but aren't) from expected memory behavior (cache warming, GC not having run yet, connection pool at steady-state size). Ask what would confirm this if the data I gave isn't enough.
2. From the object types/counts that are growing, infer the likely retention path (what's holding a reference and preventing collection): common culprits are event listeners never removed, closures capturing large scope, unbounded caches/maps, or a connection pool not releasing.
3. Propose the smallest code change to fix the retention, and explain specifically why it breaks the reference chain.
4. Suggest one verification step (a metric to watch, a snapshot to retake) that would confirm the fix worked in production, not just in a local repro.
5. If the leak is architectural (e.g. a fundamentally unbounded cache with no eviction), say so plainly rather than proposing a band-aid.
Symptoms/data: symptoms
Relevant code: code