Python Memory Growth

Find why a long-running Python process keeps growing or never returns memory. Separates a leak from retention from allocator behaviour by comparing tracemalloc totals (started with PYTHONTRACEMALLOC=25) against RSS over hours; if tracemalloc grows, diffs two snapshots with compare_to(old, 'lineno') and uses objgraph show_growth and show_backrefs to find the owner; if it stays flat while RSS grows, goes to memray --native, MALLOC_ARENA_MAX=2 or jemalloc as measured experiments; for pre-fork servers uses gc.freeze() before forking against copy-on-write bloat. Use for "gunicorn workers use more RAM every hour", "celery worker OOMKilled", "RSS never goes down after a big request", "memory doubles after fork", "leak or fragmentation". Not for CPU, latency or allocation churn in a hot path (profiling), general cause-finding (debugging), the pod's OOMKilled event (k8s-triage).

greenblacked Updated
The twenty-nine plugins: coding, family, gamedev, operations, delivery, security, manager, personal, career, design, llm, data, techdocs, assurance, client-apps

File contents

greenblacked/AI commit 9b95d8422d

Frequently asked questions

npx get-skill add greenblacked/python-memory-growth