[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BTFPKVM340RJV9WFSTNC7F":3,"skill-same:01M7BTFPKVM340RJV9WFSTNC7F":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7BTFPKVM340RJV9WFSTNC7F","heap-snapshot-analysis",null,"Analyze V8 heap snapshots to investigate memory leaks and retention issues. Use when given .heapsnapshot files, asked to compare before\u002Fafter snapshots, asked to find what retains objects, or investigating why objects survive GC. Provides snapshot parsing, comparison, retainer-path helpers, and scratchpad scripts.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: heap-snapshot-analysis\ndescription: \"Analyze V8 heap snapshots to investigate memory leaks and retention issues. Use when given .heapsnapshot files, asked to compare before\u002Fafter snapshots, asked to find what retains objects, or investigating why objects survive GC. Provides snapshot parsing, comparison, retainer-path helpers, and scratchpad scripts.\"\n---\n\n# Heap Snapshot Analysis\n\nInvestigate memory leaks from V8 heap snapshots (`.heapsnapshot` files). This skill starts when snapshots already exist: either the user provided them, DevTools exported them, or another workflow produced them. Use the helpers here to compare snapshots, group object deltas, and trace retainer paths.\n\n## IGNORE Prior Investigations\n\n**Start every investigation fresh.** Do NOT read, consult, or be influenced by prior investigations found in:\n\n- `\u002Fmemories\u002F` (user, session, or repo memory)\n- `.github\u002Fskills\u002Fheap-snapshot-analysis\u002Fscratchpad\u002F` (previous dated subfolders and their `findings.md` files)\n- Any other notes from earlier sessions\n\nPrevious findings can bias the analysis toward suspects that are no longer relevant, or cause the agent to skip steps and jump to conclusions. Let the current snapshots speak for themselves. Only reference prior work if the user explicitly asks you to.\n\n## When to Use\n\n- User provides `.heapsnapshot` files (before\u002Fafter a workflow)\n- User has heap snapshots captured by another skill or script\n- Need to find what retains disposed objects (retainer path analysis)\n- Comparing object counts\u002Fsizes between two snapshots\n- Investigating why particular objects survive GC\n\n## Workflow\n\nIf the user needs the agent to launch VS Code, drive a scenario, and capture snapshots first, use the VS Code performance workflow skill before returning here for low-level snapshot analysis.\n\n### 1. Parse Snapshots\n\nUse the helpers in [parseSnapshot.ts](.\u002Fhelpers\u002FparseSnapshot.ts) to load snapshots. The files are often >500MB and too large for `JSON.parse` as a string — the helpers use Buffer-based extraction. In scratchpad scripts, import helpers from `..\u002Fhelpers\u002F*.ts`.\n\nFor very large snapshots, the helper may still be too eager. Node cannot create a Buffer larger than roughly 2 GiB, so snapshots above that size can fail with `ERR_FS_FILE_TOO_LARGE` even before parsing. In that case, do not try to raise `--max-old-space-size` and retry the same full-file read. Switch to a streaming script.\n\n```typescript\nimport { parseSnapshot, buildGraph } from '..\u002Fhelpers\u002FparseSnapshot.ts';\n\nconst data = parseSnapshot('\u002Fpath\u002Fto\u002Fsnapshot.heapsnapshot');\nconst graph = buildGraph(data);\n```\n\n#### Snapshots Larger Than 2 GiB\n\nWhen a snapshot is too large to load into a single Buffer, write scratchpad scripts that scan and parse only the sections needed for the question. Use [streamSnapshot.mjs](.\u002Fhelpers\u002FstreamSnapshot.mjs) for the common streaming primitives instead of copying them between scratch scripts.\n\nUseful tricks:\n\n- Find top-level section offsets first. Scan the file as bytes for markers like `\"nodes\":`, `\"edges\":`, `\"strings\":`, and `\"trace_function_infos\":`. This lets follow-up scripts jump directly to the large arrays instead of searching the whole file repeatedly.\n- Parse `snapshot.meta` separately from the small header at the start of the file. Use `meta.node_fields`, `meta.node_types`, `meta.edge_fields`, and `meta.edge_types` to avoid hard-coding tuple widths.\n- Stream numeric arrays in chunks. For `nodes` and `edges`, keep a small carryover string between chunks, split on commas, and process complete numeric tokens as they arrive.\n- Avoid materializing the full `strings` table unless the investigation truly needs it. If you only need suspicious names, collect string indexes from matching nodes\u002Fedges first, then resolve only those indexes in a second streaming pass.\n- If you do need many strings, store only short previews and category counters. Full source strings, ref-listing strings, and prompt payloads can dominate memory and make the analyzer become the leak.\n- Write intermediate outputs to files in the scratchpad. Large heap analysis is iterative and slow; cached node ids, offsets, and retainer traces save repeated multi-minute passes.\n- Prefer self-size attribution and field-level ownership for huge graphs. Full retained-size walks can wildly overcount shared services, roots, maps, and singleton caches.\n- When quantifying a suspected owner, count obvious owned fields separately: wrapper object, key arrays, array elements, direct strings, and parent strings of sliced\u002Fconcatenated strings. This often gives a better lower-bound than a single direct string bucket.\n- Be explicit about approximation boundaries. A field-level subtotal usually undercounts listeners\u002Fwatchers\u002Fback-references but avoids the much worse problem of attributing the whole runtime to one object.\n\nExample large-snapshot workflow:\n\n```javascript\nimport { findArrayStart, findTokenOffsets, parseMeta, streamNumberTuples } from '..\u002F..\u002Fhelpers\u002FstreamSnapshot.mjs';\n\nconst { size, offsets } = findTokenOffsets(snapshotPath);\nconst meta = parseMeta(snapshotPath);\nconst nodeFieldCount = meta.node_fields.length;\nconst nodesStart = findArrayStart(snapshotPath, offsets.get('\"nodes\"'));\n\nstreamNumberTuples(snapshotPath, nodesStart, offsets.get('\"edges\"'), nodeFieldCount, (node, nodeIndex) => {\n    \u002F\u002F node is reused for speed; copy it before storing.\n});\n```\n\n```bash\ncd .github\u002Fskills\u002Fheap-snapshot-analysis\nnode --max-old-space-size=24576 scratchpad\u002FYYYY-MM-DD-topic\u002FfindOffsets.mjs \u002Fpath\u002Fto\u002FHeap.heapsnapshot\nnode --max-old-space-size=24576 scratchpad\u002FYYYY-MM-DD-topic\u002FstreamAnalyze.mjs \u002Fpath\u002Fto\u002FHeap.heapsnapshot > scratchpad\u002FYYYY-MM-DD-topic\u002FstreamAnalyze.out\nnode --max-old-space-size=24576 scratchpad\u002FYYYY-MM-DD-topic\u002FtraceNodes.mjs \u002Fpath\u002Fto\u002FHeap.heapsnapshot 12345 67890 > scratchpad\u002FYYYY-MM-DD-topic\u002FtraceNodes.out\n```\n\n### 2. Compare Before\u002FAfter\n\nUse [compareSnapshots.ts](.\u002Fhelpers\u002FcompareSnapshots.ts) to diff two snapshots:\n\n```typescript\nimport { compareSnapshots } from '..\u002Fhelpers\u002FcompareSnapshots.ts';\n\nconst result = compareSnapshots('\u002Fpath\u002Fto\u002Fbefore.heapsnapshot', '\u002Fpath\u002Fto\u002Fafter.heapsnapshot');\n\u002F\u002F result.topBySize, result.topByCount, result.newObjectGroups, result.summary\n```\n\n### 3. Find Retainer Paths\n\nUse [findRetainers.ts](.\u002Fhelpers\u002FfindRetainers.ts) to trace why an object is alive:\n\n```typescript\nimport { findRetainerPaths } from '..\u002Fhelpers\u002FfindRetainers.ts';\n\n\u002F\u002F Find what keeps ChatModel instances alive (skipping weak edges)\nfindRetainerPaths(graph, 'ChatModel', { maxPaths: 5, maxDepth: 25, maxAttempts: 200 });\n```\n\n### 4. Write Investigation Scripts\n\nWrite investigation-specific scripts in the [scratchpad](.\u002Fscratchpad\u002F) directory. This folder is gitignored — use it freely for one-off analysis.\n\nOrganize scratchpad work into **dated subfolders** named `YYYY-MM-DD-short-description\u002F` (e.g., `2026-04-09-chat-model-retainers\u002F`). Each subfolder should contain:\n\n- The analysis scripts (`.mjs`, `.mts`, etc.)\n- A **`findings.md`** file documenting the full investigation: all ideas considered, which ones led to changes and which were rejected (and why), before\u002Fafter measurements, and a summary of the outcome. This lets the user review the agent's reasoning, decide which changes to keep, and follow up on deferred ideas.\n\nScripts can import the helpers:\n\n```bash\ncd .github\u002Fskills\u002Fheap-snapshot-analysis\nnode --max-old-space-size=16384 scratchpad\u002F2026-04-09-chat-model-retainers\u002Fanalyze.mjs\n```\n\n## Key Concepts\n\n### V8 Heap Snapshot Format\n\nThe `.heapsnapshot` file is JSON with these key sections:\n- **`snapshot.meta`**: Field definitions for nodes and edges\n- **`nodes`**: Flat array, every N values = one node (N = `meta.node_fields.length`, typically 6: `type, name, id, self_size, edge_count, detachedness`)\n- **`edges`**: Flat array, every M values = one edge (M = `meta.edge_fields.length`, typically 3: `type, name_or_index, to_node`)\n- **`strings`**: String table indexed by `name` fields in nodes\u002Fedges\n\n### Edge Types That Matter\n\n| Type | Meaning | Prevents GC? |\n|------|---------|-------------|\n| `property` | Named JS property | Yes |\n| `element` | Array index | Yes |\n| `context` | Closure variable | Yes |\n| `internal` | V8 internal reference | Yes |\n| `hidden` | V8 hidden reference | Yes |\n| **`weak`** | WeakRef\u002FWeakMap key | **No** |\n| `shortcut` | Convenience link | Depends |\n\n**Always skip `weak` edges when tracing retainer paths.** WeakMap entries show up as edges from key → backing array, but they don't prevent collection — they're red herrings.\n\n### Common VS Code Retention Patterns\n\n1. **RowCache templates**: ListView's `RowCache` stores template rows. Templates have `currentElement` pointing to old viewmodel items. If not cleared on session switch, retains entire model chains.\n\n2. **Resource pools**: `pool.clear()` only disposes idle items. If `_onDidUpdateViewModel.fire()` runs AFTER `pool.clear()`, released items re-enter the empty pool and are never disposed. Fire event first, then clear.\n\n3. **`autorunIterableDelta` lastValues**: The closure captures a `Map` of previous iteration values. Values stay until the autorun re-runs. Async disposal delays keep models in observable stores longer than expected.\n\n4. **`HoverService._delayedHovers`**: Global singleton Map retaining disposed objects via `show` closure → `resolveHoverOptions` closure → `this`. If hover cleanup disposable doesn't fire, the entire object tree is retained.\n\n5. **`ObjectMutationLog._previous`**: The incremental serializer keeps a full snapshot of the last-serialized state. Every loaded ChatModel holds 2x its data: live + `_previous`.\n\n6. **`_previousModelRef` pattern**: `MutableDisposable` setter disposes the old value. Reading `.value` and storing it elsewhere, then setting `.value = undefined`, disposes the stored reference. Use `clearAndLeak()` to extract without disposing.\n\n### Defensive Nulling\n\nNull heavy fields in `dispose()` to break retention chains even when something retains the disposed object:\n\n```typescript\noverride dispose() {\n    super.dispose();\n    this._requests.length = 0;      \u002F\u002F conversation data\n    this.dataSerializer = undefined;  \u002F\u002F serialization snapshot\n    this._editingSession = undefined; \u002F\u002F editing session + TextModels\n    this._session = undefined!;       \u002F\u002F back-reference cycles\n}\n```\n\n**Caveat**: Don't null fields on viewmodel items (`ChatResponseViewModel._model`). The tree's `diffIdentityProvider` accesses them after the parent viewmodel is disposed but before `setChildren` replaces them.\n\n### False Retainers to Watch For\n\n- **DevTools debugger global handles**: If the snapshot was captured after opening DevTools, large source strings, compiled scripts, preview data, inspected objects, or debugger bookkeeping can be retained by paths like `DevTools debugger(internal)` → `synthetic::(Global handles)` → GC roots. Treat these as debugger-induced until proven otherwise. They may not exist in the app before DevTools opens, and they should not be confused with application-owned leaks.\n- **`DevToolsLogger._aliveInstances`** (Map): Enabled by `VSCODE_DEV_DEBUG_OBSERVABLES` env var. Retains ALL observed observables. Check if this is active before investigating observable-rooted paths.\n- **`GCBasedDisposableTracker` (FinalizationRegistry)**: If `register(target, held, target)` is used (target === unregister token), creates a strong self-reference preventing GC. Currently commented out in production.\n- **WeakMap backing arrays**: Show up in retainer paths but don't prevent collection.\n\n## Running Analysis\n\nAll helper scripts use ESM and need Node with extra memory:\n\n```bash\nnode --max-old-space-size=16384 scratchpad\u002Fanalyze.mjs\n```\n\nTypical analysis takes 30-120 seconds per snapshot depending on size.\n","# Heap Snapshot Analysis\n\nInvestigate memory leaks from V8 heap snapshots (`.heapsnapshot` files). This skill starts when snapshots already exist: either the user provided them, DevTools exported them, or another workflow produced them. Use the helpers here to compare snapshots, group object deltas, and trace retainer paths.\n\n## IGNORE Prior Investigations\n\n**Start every investigation fresh.** Do NOT read, consult, or be influenced by prior investigations found in:\n\n- `\u002Fmemories\u002F` (user, session, or repo memory)\n- `.github\u002Fskills\u002Fheap-snapshot-analysis\u002Fscratchpad\u002F` (previous dated subfolders and their `findings.md` files)\n- Any other notes from earlier sessions\n\nPrevious findings can bias the analysis toward suspects that are no longer relevant, or cause the agent to skip steps and jump to conclusions. Let the current snapshots speak for themselves. Only reference prior work if the user explicitly asks you to.\n\n## When to Use\n\n- User provides `.heapsnapshot` files (before\u002Fafter a workflow)\n- User has heap snapshots captured by another skill or script\n- Need to find what retains disposed objects (retainer path analysis)\n- Comparing object counts\u002Fsizes between two snapshots\n- Investigating why particular objects survive GC\n\n## Workflow\n\nIf the user needs the agent to launch VS Code, drive a scenario, and capture snapshots first, use the VS Code performance workflow skill before returning here for low-level snapshot analysis.\n\n### 1. Parse Snapshots\n\nUse the helpers in [parseSnapshot.ts](.\u002Fhelpers\u002FparseSnapshot.ts) to load snapshots. The files are often >500MB and too large for `JSON.parse` as a string — the helpers use Buffer-based extraction. In scratchpad scripts, import helpers from `..\u002Fhelpers\u002F*.ts`.\n\nFor very large snapshots, the helper may still be too eager. Node cannot create a Buffer larger than roughly 2 GiB, so snapshots above that size can fail with `ERR_FS_FILE_TOO_LARGE` even before parsing. In that case, do not try to raise `--max-old-space-size` and retry the same full-file read. Switch to a streaming script.\n\n```typescript\nimport { parseSnapshot, buildGraph } from '..\u002Fhelpers\u002FparseSnapshot.ts';\n\nconst data = parseSnapshot('\u002Fpath\u002Fto\u002Fsnapshot.heapsnapshot');\nconst graph = buildGraph(data);\n```\n\n#### Snapshots Larger Than 2 GiB\n\nWhen a snapshot is too large to load into a single Buffer, write scratchpad scripts that scan and parse only the sections needed for the question. Use [streamSnapshot.mjs](.\u002Fhelpers\u002FstreamSnapshot.mjs) for the common streaming primitives instead of copying them between scratch scripts.\n\nUseful tricks:\n\n- Find top-level section offsets first. Scan the file as bytes for markers like `\"nodes\":`, `\"edges\":`, `\"strings\":`, and `\"trace_function_infos\":`. This lets follow-up scripts jump directly to the large arrays instead of searching the whole file repeatedly.\n- Parse `snapshot.meta` separately from the small header at the start of the file. Use `meta.node_fields`, `meta.node_types`, `meta.edge_fields`, and `meta.edge_types` to avoid hard-coding tuple widths.\n- Stream numeric arrays in chunks. For `nodes` and `edges`, keep a small carryover string between chunks, split on commas, and process complete numeric tokens as they arrive.\n- Avoid materializing the full `strings` table unless the investigation truly needs it. If you only need suspicious names, collect string indexes from matching nodes\u002Fedges first, then resolve only those indexes in a second streaming pass.\n- If you do need many strings, store only short previews and category counters. Full source strings, ref-listing strings, and prompt payloads can dominate memory and make the analyzer become the leak.\n- Write intermediate outputs to files in the scratchpad. Large heap analysis is iterative and slow; cached node ids, offsets, and retainer traces save repeated multi-minute passes.\n- Prefer self-size attribution and field-level ownership for huge graphs. Full retained-size walks can wildly overcount shared services, roots, maps, and singleton caches.\n- When quantifying a suspected owner, count obvious owned fields separately: wrapper object, key arrays, array elements, direct strings, and parent strings of sliced\u002Fconcatenated strings. This often gives a better lower-bound than a single direct string bucket.\n- Be explicit about approximation boundaries. A field-level subtotal usually undercounts listeners\u002Fwatchers\u002Fback-references but avoids the much worse problem of attributing the whole runtime to one object.\n\nExample large-snapshot workflow:\n\n```javascript\nimport { findArrayStart, findTokenOffsets, parseMeta, streamNumberTuples } from '..\u002F..\u002Fhelpers\u002FstreamSnapshot.mjs';\n\nconst { size, offsets } = findTokenOffsets(snapshotPath);\nconst meta = parseMeta(snapshotPath);\nconst nodeFieldCount = meta.node_fields.length;\nconst nodesStart = findArrayStart(snapshotPath, offsets.get('\"nodes\"'));\n\nstreamNumberTuples(snapshotPath, nodesStart, offsets.get('\"edges\"'), nodeFieldCount, (node, nodeIndex) => {\n    \u002F\u002F node is reused for speed; copy it before storing.\n});\n```\n\n```bash\ncd .github\u002Fskills\u002Fheap-snapshot-analysis\nnode --max-old-space-size=24576 scratchpad\u002FYYYY-MM-DD-topic\u002FfindOffsets.mjs \u002Fpath\u002Fto\u002FHeap.heapsnapshot\nnode --max-old-space-size=24576 scratchpad\u002FYYYY-MM-DD-topic\u002FstreamAnalyze.mjs \u002Fpath\u002Fto\u002FHeap.heapsnapshot > scratchpad\u002FYYYY-MM-DD-topic\u002FstreamAnalyze.out\nnode --max-old-space-size=24576 scratchpad\u002FYYYY-MM-DD-topic\u002FtraceNodes.mjs \u002Fpath\u002Fto\u002FHeap.heapsnapshot 12345 67890 > scratchpad\u002FYYYY-MM-DD-topic\u002FtraceNodes.out\n```\n\n### 2. Compare Before\u002FAfter\n\nUse [compareSnapshots.ts](.\u002Fhelpers\u002FcompareSnapshots.ts) to diff two snapshots:\n\n```typescript\nimport { compareSnapshots } from '..\u002Fhelpers\u002FcompareSnapshots.ts';\n\nconst result = compareSnapshots('\u002Fpath\u002Fto\u002Fbefore.heapsnapshot', '\u002Fpath\u002Fto\u002Fafter.heapsnapshot');\n\u002F\u002F result.topBySize, result.topByCount, result.newObjectGroups, result.summary\n```\n\n### 3. Find Retainer Paths\n\nUse [findRetainers.ts](.\u002Fhelpers\u002FfindRetainers.ts) to trace why an object is alive:\n\n```typescript\nimport { findRetainerPaths } from '..\u002Fhelpers\u002FfindRetainers.ts';\n\n\u002F\u002F Find what keeps ChatModel instances alive (skipping weak edges)\nfindRetainerPaths(graph, 'ChatModel', { maxPaths: 5, maxDepth: 25, maxAttempts: 200 });\n```\n\n### 4. Write Investigation Scripts\n\nWrite investigation-specific scripts in the [scratchpad](.\u002Fscratchpad\u002F) directory. This folder is gitignored — use it freely for one-off analysis.\n\nOrganize scratchpad work into **dated subfolders** named `YYYY-MM-DD-short-description\u002F` (e.g., `2026-04-09-chat-model-retainers\u002F`). Each subfolder should contain:\n\n- The analysis scripts (`.mjs`, `.mts`, etc.)\n- A **`findings.md`** file documenting the full investigation: all ideas considered, which ones led to changes and which were rejected (and why), before\u002Fafter measurements, and a summary of the outcome. This lets the user review the agent's reasoning, decide which changes to keep, and follow up on deferred ideas.\n\nScripts can import the helpers:\n\n```bash\ncd .github\u002Fskills\u002Fheap-snapshot-analysis\nnode --max-old-space-size=16384 scratchpad\u002F2026-04-09-chat-model-retainers\u002Fanalyze.mjs\n```\n\n## Key Concepts\n\n### V8 Heap Snapshot Format\n\nThe `.heapsnapshot` file is JSON with these key sections:\n- **`snapshot.meta`**: Field definitions for nodes and edges\n- **`nodes`**: Flat array, every N values = one node (N = `meta.node_fields.length`, typically 6: `type, name, id, self_size, edge_count, detachedness`)\n- **`edges`**: Flat array, every M values = one edge (M = `meta.edge_fields.length`, typically 3: `type, name_or_index, to_node`)\n- **`strings`**: String table indexed by `name` fields in nodes\u002Fedges\n\n### Edge Types That Matter\n\n| Type | Meaning | Prevents GC? |\n|------|---------|-------------|\n| `property` | Named JS property | Yes |\n| `element` | Array index | Yes |\n| `context` | Closure variable | Yes |\n| `internal` | V8 internal reference | Yes |\n| `hidden` | V8 hidden reference | Yes |\n| **`weak`** | WeakRef\u002FWeakMap key | **No** |\n| `shortcut` | Convenience link | Depends |\n\n**Always skip `weak` edges when tracing retainer paths.** WeakMap entries show up as edges from key → backing array, but they don't prevent collection — they're red herrings.\n\n### Common VS Code Retention Patterns\n\n1. **RowCache templates**: ListView's `RowCache` stores template rows. Templates have `currentElement` pointing to old viewmodel items. If not cleared on session switch, retains entire model chains.\n\n2. **Resource pools**: `pool.clear()` only disposes idle items. If `_onDidUpdateViewModel.fire()` runs AFTER `pool.clear()`, released items re-enter the empty pool and are never disposed. Fire event first, then clear.\n\n3. **`autorunIterableDelta` lastValues**: The closure captures a `Map` of previous iteration values. Values stay until the autorun re-runs. Async disposal delays keep models in observable stores longer than expected.\n\n4. **`HoverService._delayedHovers`**: Global singleton Map retaining disposed objects via `show` closure → `resolveHoverOptions` closure → `this`. If hover cleanup disposable doesn't fire, the entire object tree is retained.\n\n5. **`ObjectMutationLog._previous`**: The incremental serializer keeps a full snapshot of the last-serialized state. Every loaded ChatModel holds 2x its data: live + `_previous`.\n\n6. **`_previousModelRef` pattern**: `MutableDisposable` setter disposes the old value. Reading `.value` and storing it elsewhere, then setting `.value = undefined`, disposes the stored reference. Use `clearAndLeak()` to extract without disposing.\n\n### Defensive Nulling\n\nNull heavy fields in `dispose()` to break retention chains even when something retains the disposed object:\n\n```typescript\noverride dispose() {\n    super.dispose();\n    this._requests.length = 0;      \u002F\u002F conversation data\n    this.dataSerializer = undefined;  \u002F\u002F serialization snapshot\n    this._editingSession = undefined; \u002F\u002F editing session + TextModels\n    this._session = undefined!;       \u002F\u002F back-reference cycles\n}\n```\n\n**Caveat**: Don't null fields on viewmodel items (`ChatResponseViewModel._model`). The tree's `diffIdentityProvider` accesses them after the parent viewmodel is disposed but before `setChildren` replaces them.\n\n### False Retainers to Watch For\n\n- **DevTools debugger global handles**: If the snapshot was captured after opening DevTools, large source strings, compiled scripts, preview data, inspected objects, or debugger bookkeeping can be retained by paths like `DevTools debugger(internal)` → `synthetic::(Global handles)` → GC roots. Treat these as debugger-induced until proven otherwise. They may not exist in the app before DevTools opens, and they should not be confused with application-owned leaks.\n- **`DevToolsLogger._aliveInstances`** (Map): Enabled by `VSCODE_DEV_DEBUG_OBSERVABLES` env var. Retains ALL observed observables. Check if this is active before investigating observable-rooted paths.\n- **`GCBasedDisposableTracker` (FinalizationRegistry)**: If `register(target, held, target)` is used (target === unregister token), creates a strong self-reference preventing GC. Currently commented out in production.\n- **WeakMap backing arrays**: Show up in retainer paths but don't prevent collection.\n\n## Running Analysis\n\nAll helper scripts use ESM and need Node with extra memory:\n\n```bash\nnode --max-old-space-size=16384 scratchpad\u002Fanalyze.mjs\n```\n\nTypical analysis takes 30-120 seconds per snapshot depending on size.\n",{"name":5,"description":7},"main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill heap-snapshot-analysis",{"tool":39,"command":40},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill heap-snapshot-analysis",{"tool":42,"command":43},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill heap-snapshot-analysis","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis\u002FSKILL.md",true,[47,53,57,61,65,71],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"helpers\u002FcompareSnapshots.ts","SCRIPT","脚本",6109,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis\u002Fhelpers\u002FcompareSnapshots.ts",{"path":54,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":55,"sourceHtmlUrl":56},"helpers\u002FfindRetainers.ts",4942,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis\u002Fhelpers\u002FfindRetainers.ts",{"path":58,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":59,"sourceHtmlUrl":60},"helpers\u002FparseSnapshot.ts",7536,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis\u002Fhelpers\u002FparseSnapshot.ts",{"path":62,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":63,"sourceHtmlUrl":64},"helpers\u002FstreamSnapshot.mjs",6926,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis\u002Fhelpers\u002FstreamSnapshot.mjs",{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"scratchpad\u002F.gitignore","OTHER","其他",25,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis\u002Fscratchpad\u002F.gitignore",{"path":72,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},"scratchpad\u002FREADME.md","REFERENCE","参考文档",810,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-IDE-编辑器内核\u002FYYC3-IDE-编辑器内核-vscode\u002F.github\u002Fskills\u002Fheap-snapshot-analysis\u002Fscratchpad\u002FREADME.md",[78,85,92,99,106,113],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]