Skip to content

Commit 8062d47

Browse files
committed
feat: update memory debugging skill
1 parent 5e961a6 commit 8062d47

3 files changed

Lines changed: 21 additions & 46 deletions

File tree

skills/memory-leak-debugging/SKILL.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ This skill provides expert guidance and workflows for finding, diagnosing, and f
1515

1616
## Workflows
1717

18-
### 1. Using Memlab (Recommended)
18+
### 1. Capturing Snapshots
1919

20-
When users provide `.heapsnapshot` files or want to find a memory leak, use `memlab` to automatically find memory leaks.
20+
When investigating a frontend web application memory leak, utilize the `chrome-devtools-mcp` tools to interact with the application and take snapshots.
21+
- Use tools like `click`, `navigate_page`, `fill`, etc., to manipulate the page into the desired state.
22+
- Revert the page back to the original state after interactions to see if memory is released.
23+
- Repeat the same user interactions 10 times to amplify the leak.
24+
- Use `take_memory_snapshot` to save `.heapsnapshot` files to disk at baseline, target (after actions), and final (after reverting actions) states.
2125

22-
- Read [references/memlab.md](references/memlab.md) for how to use `memlab` to analyze existing heapsnapshots or run automated E2E test scenarios to find leaks.
26+
### 2. Using Memlab to Find Leaks (Recommended)
27+
28+
Once you have generated `.heapsnapshot` files using `take_memory_snapshot`, use `memlab` to automatically find memory leaks.
29+
30+
- Read [references/memlab.md](references/memlab.md) for how to use `memlab` to analyze the generated heapsnapshots.
2331
- Do **not** read raw `.heapsnapshot` files using `read_file` or `cat`.
2432

25-
### 2. Identifying Common Leaks
33+
### 3. Identifying Common Leaks
2634

2735
When you have found a leak trace (e.g., via `memlab` output), you must identify the root cause in the code.
2836

2937
- Read [references/common-leaks.md](references/common-leaks.md) for examples of common memory leaks and how to fix them.
30-
31-
### 3. Creating Memlab Scenarios
32-
33-
To help users reproduce and test for leaks automatically, you can create a Memlab scenario file.
34-
35-
- An example template is available at `scripts/memlab-scenario.js`.

skills/memory-leak-debugging/references/memlab.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,25 @@
44

55
## Important Rule
66

7-
**NEVER read raw `.heapsnapshot` files directly.** They are too large and will exceed context limits. Use `memlab` commands to analyze them instead.
7+
**NEVER read raw `.heapsnapshot` files directly.** They are too large and will exceed context limits. Always use `memlab` commands to analyze them.
88

9-
## Analyzing Existing Snapshots
9+
## Analyzing Snapshots
1010

11-
If the user provides 3 snapshots (baseline, target, final), you can use `memlab` to find leaks:
11+
You can use the `take_memory_snapshot` tool provided by the `chrome-devtools-mcp` extension to generate heap snapshots during an investigation. To find leaks, you generally need 3 snapshots:
12+
1. **Baseline:** Before the suspect action.
13+
2. **Target:** After the suspect action.
14+
3. **Final:** After reverting the suspect action (e.g., closing a modal, navigating away).
15+
16+
Once you have these 3 snapshots saved to disk, you can use `memlab` to find leaks:
1217

1318
```bash
1419
npx memlab find-leaks --baseline <path-to-baseline> --target <path-to-target> --final <path-to-final>
1520
```
1621

17-
You can also parse a single snapshot to find the largest objects:
22+
You can also parse a single snapshot to find the largest objects or explore it individually:
1823

1924
```bash
2025
npx memlab analyze snapshot --snapshot <path-to-snapshot>
2126
```
2227

23-
## Running Automated Scenarios
24-
25-
Memlab can automatically open a browser, interact with a page, take snapshots, and find leaks.
26-
You need a scenario file (e.g., `scenario.js`).
27-
28-
```bash
29-
npx memlab run --scenario <path-to-scenario.js>
30-
```
31-
3228
Memlab will output the retainer traces for identified leaks. Use these traces to guide your search in the codebase.

skills/memory-leak-debugging/scripts/memlab-scenario.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)