More screenshots

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Python Memory Leak Triage for OOMKilled Containers

    1

    Find the leaking line in a live Python container before the next OOMKill, without restarting it.

    $15

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Python Memory Leak Triage for OOMKilled Containers

    Python Memory Leak Triage for OOMKilled Containers

    Example session with this skill installed

    Our orders-api container gets OOMKilled every few hours. Find the leak, but don't restart it.

    • Read your context and instructions
    • Compiled the python memory leak

    The agent first checks what the kernel killed and whether it was heap: ```text $ scripts/mem_evidence.py --oom-history pid 566 (python) killed: anon 509.1 MiB, file 280.0 KiB, shmem 0 B -> mostly anon/heap constraint: cgroup limit (the container/pod hit ITS OWN limit) ``` Then it measures the live replica under normal load: ```text $ scripts/mem_evidence.py --container orders-api --samples 6 --interval 10 usage 136.1 MiB working_set 121.3 MiB limit 512.0 MiB anon 118.3 MiB file 16.3 MiB (inactive 14.8 MiB) shmem 0 B [WARN] eta-to-limit: the working set reaches the limit in ~4 min. [WARN] anon-growth: PID 18891 (Python) grows 92.3 MiB/min (R²=1.00): this is heap growth. ``` It shows the attach plan, gets a yes, and captures 20 seconds of allocations: ```text $ scripts/live_capture.sh alloc --container orders-api --duration 20 --execute [ok] memray importable by target interpreter (1.20.0) [ok] Python 3.14: memray uses sys.remote_exec (PEP 768), no gdb/lldb needed [ok] 72.9% free under the memory limit leaks: 39.6 MiB in 126 distinct stacks 39.5 MiB 99.7% 1262 allocs quote (/app/orders_api.py:9) <- do_GET (/app/orders_api.py:14) ``` **Result:** line 9 stores every quote in a module-level dict whose key contains a timestamp, so it never hits and never evicts. The fix is a bounded TTL cache keyed on the order id. The service was never restarted.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    **Your Python container climbs to its limit and gets OOMKilled every few hours.** This skill makes your agent prove *what* is growing (heap, page cache, tmpfs or kernel memory, and which worker), then attach to the live process with py-spy and memray and name the file and line. *No restart, no "just raise the limit".* ### Why this instead of a free skill Free memory-leak skills review your code for patterns or tell the model to "use memray". None of them checks whether it is a leak at all, picks the right gunicorn/celery worker, or knows that memray attach from the host into a container fails (it has to run inside; this skill does that for you). Every script was run against real Docker containers driven to a real OOM kill, on Python 3.12, 3.13 and 3.14. ### What is inside - `mem_evidence.py`: cgroup v1/v2 + /proc evidence, growth rate per process with R², time left before the limit, plain-language verdicts. `--oom-history` reads kernel OOM kills and tells a container-limit kill from a host OOM. - `live_capture.sh`: preflight (ptrace, debugger, memray importable by the target, memory headroom), py-spy stacks, bounded memray attach with a plain-text leak report, `detach` as rollback. - Python 3.14 without gdb (PEP 768 `sys.remote_exec`); gdb/lldb path for 3.8 to 3.13. - `leak_probe.py` + `snapshot_diff.py`: a two-line opt-in tracemalloc probe driven by `kill -USR2`; the diff separates real leaks (grew in every interval) from warm-up. - 11 production leak patterns with the fix, malloc arena fragmentation (`MALLOC_ARENA_MAX`), Kubernetes `kubectl debug` recipes. - 6 Prometheus alerts (working set vs limit, `predict_linear`, monotonic RSS, OOMKilled) with promtool unit tests, so the next leak pages you hours before the kill. ### How it keeps you safe - Read-only evidence first: nothing is restarted or changed. - Dry-run by default. Injecting memray needs `--execute`, a typed confirmation, a memory headroom check and a bounded duration. - `detach` stops tracking at once; the tracemalloc probe switches itself off after N snapshots. - No `py-spy --locals` (locals hold secrets). ### Requirements Linux (cgroup v1 or v2), root or CAP_SYS_PTRACE, Python 3.8+. py-spy and memray for the live capture steps; the evidence and diff scripts are standard library only. Docker 23+ for container mode.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for DevOps & Cloud.

    Not for: Node, JVM or Go services, CPU or latency profiling, or a container that is already dead and only needs crash evidence and disk cleanup. memray attach needs a glibc-based Python (not musl/Alpine).

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 4 days ago

    Linux only

    Software
    Python 3.8+
    root
    orCAP_SYS_PTRACE
    Optional
    py-spy and memray (live capture)Docker 23+ (container mode)

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Environment Variables

    Shell: python3, docker, py-spy, memray; root or CAP_SYS_PTRACE for attaching. Files: reads /proc and /sys/fs/cgroup; writes a capture folder in the current directory and a temporary file in the target's /tmp (copied out and deleted). Network: none. Services: Docker Engine (container mode).

    Listed4 days ago

    What's inside

    Frequently Asked Questions

    No. py-spy and memray attach work on the running process. leak_probe.py (two lines) is only the fallback when memray cannot be installed where the service runs.

    Yes, memray attach imports memray in the target process. If it is not there, preflight says so and the skill offers the options (py-spy stacks right away, the probe in the next deploy, or a temporary install on one replica) without doing any of them on its own.

    Evidence and stacks are read-only. The memray attach is bounded in time, refused when memory headroom is low, needs a typed confirmation and can be stopped with detach. A small crash risk on unusual Python builds remains, and the skill says so before attaching.

    Any agent that loads SKILL.md folders: Claude Code (~/.claude/skills), Codex, Cursor and compatible tools.

    v1.x updates are included. A changelog ships with every release.

    New in DevOps & Cloud