agentleFS
mejbaurbaharmejbaurbahar/software-tester-skills/skills/memory-leak-resource-testing/SKILL.md

memory-leak-resource-testing

Skill1 starsChanged 53 days agoMITView on GitHub

Use when diagnosing or preventing memory leaks, unbounded growth, file-descriptor/connection/thread leaks, GC pressure, OOM kills, and slow degradation in long-running services, browsers, and mobile apps — heap snapshots, profilers, soak tests.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run a soak test at steady load 1–24 h (performance-testing).

    line 16

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Memory Leak & Resource Testing

Symptom: memory/handles/latency grow with time or request count and never plateau; ends with OOM-kill, EMFILE, or timeouts.

Detect (black-box first)

  1. Run a soak test at steady load 1–24 h (performance-testing).
  2. Chart RSS, heap-used, open FDs, thread count, DB connections, GC pause, queue depth. Healthy = sawtooth around a plateau; leak = rising baseline after each GC.
  3. Force GC (where possible) and compare post-GC baselines at t0 vs t+N.
# Linux / container quick checks
ls /proc/$PID/fd | wc -l                     # FD count over time
ps -o rss,vsz,nlwp -p $PID                   # RSS, VSZ, threads
lsof -p $PID | awk '{print $5}' | sort | uniq -c | sort -rn | head
kubectl top pod --containers; kubectl describe pod | grep -i oomkilled

Find the owner (white-box)

StackTooling
Node.jsnode --inspect, Chrome DevTools heap snapshots (3-snapshot diff), clinic doctor/heapprofiler, --heapsnapshot-signal=SIGUSR2
Browser/SPADevTools Memory tab → "Allocation instrumentation on timeline", detached DOM nodes, performance.measureUserAgentSpecificMemory(); Puppeteer loop + heap check
Pythontracemalloc, objgraph, memray run, py-spy dump
Java/JVMJFR, jcmd GC.heap_dump, Eclipse MAT dominator tree, -XX:+HeapDumpOnOutOfMemoryError
Gopprof heap/goroutine profiles (/debug/pprof/heap), goroutine leak detection goleak
NativeValgrind/heaptrack, ASan LeakSanitizer
Android/iOSAndroid Studio Profiler / LeakCanary; Xcode Instruments Leaks & Allocations

Typical root causes

Unbounded caches/maps · listeners/subscriptions never removed · timers/intervals not cleared · closures holding large objects · detached DOM nodes · unclosed streams/cursors/connections · thread/goroutine leaks (blocked channel) · growing logs/metrics label cardinality · ThreadLocal misuse · session stores without TTL.

Regression test ideas

// Jest + node: loop operation and assert bounded growth
global.gc(); const a = process.memoryUsage().heapUsed;
for (let i=0;i<10000;i++) handle(sampleReq());
global.gc(); const b = process.memoryUsage().heapUsed;
expect(b - a).toBeLessThan(5 * 1024 * 1024);   // run with node --expose-gc

Also: repeat-navigation loop in Playwright then compare heap; goroutine count before/after (goleak.VerifyNone(t)); connection-pool active == 0 after test.

Report

Growth rate (MB/h), load profile, first-seen build, retained-object class + retainer path, minimal repro, suggested fix (bound/evict/close/unsubscribe).

Related

performance-testing, observability-testing, chaos-resilience-testing, mobile-testing

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.