Skip to content
Back to skills

Memory

ASecurity

Detect and fix memory leaks. Instruments memory tracking across thousands of iterations, proves the leak with growth data, identifies the uncollected reference, and verifies the fix.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 26, 2026
developmentpythonshellnode

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add v0idOS/performance-deity --skill memory --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Memory?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Memory
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/v0idos-memory/badge)](https://www.skillsdirectory.com/skills/v0idos-memory)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Detect and fix memory leaks. Instruments memory tracking across thousands of iterations, proves the leak with growth data, identifies the uncollected reference, and verifies the fix.
---

Execute all four phases in order.

## Phase 1 — Isolation

1. Identify the code suspected of leaking.
2. Write a wrapper that runs it in an infinite loop or for ≥1,000,000 iterations.

## Phase 2 — Instrumentation

Inject memory tracking into the wrapper:
- Node.js: `process.memoryUsage().heapUsed` before and after each iteration.
- Python: `tracemalloc.start()` / `tracemalloc.get_traced_memory()`.
- PowerShell: `[System.GC]::GetTotalMemory($false)`.

If memory continuously grows without recovering after GC, the leak is confirmed. Show the growth numerically:
```
Iteration      0:  10 MB
Iteration 100k:  14 MB
Iteration 500k:  40 MB
```

## Phase 3 — Fix

Identify the uncollected reference:
- Event listeners not removed from detached DOM nodes
- Global arrays or caches growing without a size limit
- Closures retaining large outer-scope objects

Apply the fix:
- `removeEventListener` for DOM event listeners
- `WeakMap` / `WeakRef` for object-keyed associations that should not prevent GC
- Object pooling to reuse memory instead of allocating new objects per cycle

## Phase 4 — Report

Re-run the instrumented wrapper and present:

| Metric | Before | After |
|---|---|---|
| Memory growth per 10k ops | +50MB | +0MB |
| GC pause frequency | High | Stable |

Explain the root cause and the specific reference that was being retained.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.