Skip to content

Commit 5915ff1

Browse files
committed
feat: Update skill recommendations
1 parent 1db1017 commit 5915ff1

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

skills/memory-leak-debugging/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This skill provides expert guidance and workflows for finding, diagnosing, and f
1111

1212
- **Prefer `memlab`:** Do NOT attempt to read raw `.heapsnapshot` files directly, as they are extremely large and will consume too many tokens. Always recommend and use `memlab` to process snapshots and identify leak traces.
1313
- **Isolate the Leak:** Determine if the leak is in the browser (client-side) or Node.js (server-side).
14-
- **Common Culprits:** Look for detached DOM nodes, unhandled closures, global variables, event listeners not being removed, and caches growing unbounded.
14+
- **Common Culprits:** Look for detached DOM nodes, unhandled closures, global variables, event listeners not being removed, and caches growing unbounded. *Note: Detached DOM nodes are sometimes intentional caches; always ask the user before nulling them.*
1515

1616
## Workflows
1717

skills/memory-leak-debugging/references/common-leaks.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
When analyzing a retainer trace from `memlab`, look for these common patterns in the codebase:
44

5-
## 1. Detached DOM Nodes
5+
## 1. Uncleared Event Listeners
66

7-
A DOM node is removed from the document tree but is still referenced by a JavaScript variable.
7+
Event listeners attached to global objects (like `window` or `document`) or long-living objects prevent garbage collection of the objects referenced in their callbacks.
88

9-
**Fix:** Ensure variables holding DOM references are set to `null` when the node is removed, or limit their scope.
9+
**Fix:** Always call `removeEventListener` when a component unmounts or the listener is no longer needed.
1010

11-
## 2. Uncleared Event Listeners
11+
## 2. Detached DOM Nodes
1212

13-
Event listeners attached to global objects (like `window` or `document`) or long-living objects prevent garbage collection of the objects referenced in their callbacks.
13+
A DOM node is removed from the document tree but is still referenced by a JavaScript variable. While detachedness is a good signal for a memory leak, it's not always a bug. For example, websites sometimes intentionally cache detached navigation trees.
1414

15-
**Fix:** Always call `removeEventListener` when a component unmounts or the listener is no longer needed.
15+
**Fix:** Signal the detached nodes to the user first. **Ask the user first** before nulling the references or changing the code, as the detached nodes might be part of an intentional cache. If confirmed as a leak, ensure variables holding DOM references are set to `null` when the node is removed, or limit their scope.
1616

1717
## 3. Unintentional Global Variables
1818

0 commit comments

Comments
 (0)