memlab-analyze-heap-snapshot
यह क्या करती है
यह memlab टूल से Chrome, Node.js, Electron या React Native के heap snapshot पढ़ती है और देखती है कि मेमोरी क्यों बढ़ती जा रही है। यह उन डेवलपर्स के लिए है जो JavaScript ऐप की मेमोरी या क्रैश की समस्या ढूँढ रहे हैं।
कब इस्तेमाल करें
- ✓जब आपके पास heap snapshot फ़ाइल है और आप जानना चाहते हैं कि मेमोरी कौन इस्तेमाल कर रहा है।
- ✓जब आपके JavaScript ऐप की मेमोरी लगातार बढ़ती है या वह मेमोरी खत्म हो जाती है।
- ✓जब आपको ब्राउज़र ऐप में डिटैच्ड DOM एलिमेंट या बढ़ते कैश पर शक हो।
Skill का लिंक
https://github.com/meta/memlab/blob/main/plugins/memlab/skills/memlab-analyze-heap-snapshot/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे Node सर्वर से यह app.heapsnapshot है। बताइए कि मेमोरी में क्या लगातार बढ़ रहा है और उसका समाधान सुझाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
आपका एजेंट snapshot को memlab में लोड करता है, उसके त्वरित निदान और जाँच टूल चलाता है, और उस संदर्भ-श्रृंखला को ट्रेस करता है जो ऑब्जेक्ट को ज़िंदा रखती है। फिर इन नतीजों के आधार पर सुधार सुझाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Analyze a JavaScript heap snapshot with memlab
memlab parses a V8 or Hermes heap snapshot into a queryable graph and answers questions about it: what fills the heap, what keeps growing, and which chain of references keeps an object alive.
1. Get the tools
MCP tools available (names start with
memlab_): use them directly.No MCP tools: use
memlab-cli, which runs the same tools from a shell. Onecallruns several tools in one server session, so load the snapshot and analyze it in the same command:npx -y -p @memlab/mcp-server memlab-cli call \ memlab_load_snapshot '{"file_path":"/abs/path/app.heapsnapshot"}' \ memlab_quick_diagnosis '{}' \ memlab_auto_investigate '{}'Each
callstarts a new server and reloads the snapshot. For an investigation with many steps, keep one server running instead; see references/memlab-cli.md.If the user wants the MCP server set up permanently, suggest the memlab plugin, which also installs these skills:
claude plugin marketplace add meta/memlabthenclaude plugin install memlab@memlab(Claude Code), orcodex plugin marketplace add meta/memlabthencodex plugin add memlab@memlab(Codex). For the server alone, give themclaude mcp add memlab -e NODE_OPTIONS=--max-old-space-size=8192 -- npx -y -p @memlab/mcp-server memlab-mcp(Claude Code) or the JSON config in the MCP server docs. Keep--max-old-space-size=8192or higher: without it, large snapshots are refused.
2. Get the snapshot
memlab_load_snapshottakes a local absolute path. If only<path>.gzexists, pass<path>and the server decompresses it. Download remote snapshots first.- For a file over about 1 GB, call
memlab_snapshot_headerfirst. It reads node and edge counts without parsing the graph and says whether the snapshot will load. - One snapshot shows what is in memory. To show what grows, you need two
or more snapshots taken from the same page or process while an interaction
repeats. If the user has none, see the
memlab-capture-heap-snapshotsskill or the memlab docs.
3. Triage
memlab_load_snapshotwith the path. Read the quick diagnosis it returns.- In parallel (all analysis tools are read-only once a snapshot is loaded):
memlab_quick_diagnosis: summary, top objects, class histogram, duplicated strings.memlab_auto_investigate: top retainers with retainer chains and severity, pinch points, unbounded caches, pending promises, known framework leak patterns.
memlab_app_heapto split the heap into application data, bundle source and engine internals before blaming the app for the total.- Note whether it is a browser or a Node.js heap; DOM tools only apply to browser snapshots.
4. Follow the matching path
Pick the path that fits the triage result. Each path is a short tool sequence in references/investigation-paths.md.
| Triage shows | Path |
|---|---|
| Many duplicated or huge strings | A: String waste |
| Detached DOM elements (browser) | B: DOM leaks |
| A class with very many instances, or one object retaining >5% of the heap | C: Object accumulation |
| Large closures in retainer chains | D: Closure leaks |
| Large non-built-in globals | E: Global variables |
| Many callback/listener/handler objects | F: Listener accumulation |
Many identical Error objects |
G: Repeated errors |
| Metric, cache key or record field with huge value cardinality | H: Cardinality explosion |
| Only one snapshot, need a growth guess | I: Single-snapshot growth signals |
| Three or more snapshots in order | J: Trend across snapshots |
| Huge detached tree in a browser snapshot, possibly from DevTools | K: Real leak or dev artifact |
5. Explain the retention
For the suspect object:
memlab_retainer_tracewith itsnode_id: the shortest path from a GC root. Useexpand: truewhen the interesting frame is hidden in an elided run.memlab_retainer_layerswith the samenode_idbefore proposing a fix. It lists every independent retaining path; cutting one edge frees nothing if another path still holds the object.memlab_closure_inspectionwhen a closure (or a suspended async function) is in the chain: it shows the captured variables and their s
अक्सर पूछे जाने वाले सवाल
heap snapshot कहाँ से मिलता है?
इसे कैप्चर करने का तरीका एक अलग स्किल में है, जो Chrome, Edge, Node.js, Electron या React Native से snapshot लेना समझाती है।
क्या इसके लिए कोई खास सेटअप चाहिए?
अगर memlab टूल सर्वर के रूप में सेट नहीं हैं, तो स्किल npx के ज़रिए memlab कमांड-लाइन से चला सकती है।
क्या यह बताएगी कि ऑब्जेक्ट मेमोरी में क्यों रहता है?
हाँ। यह उस संदर्भ-श्रृंखला को ट्रेस करती है जो ऑब्जेक्ट को ज़िंदा रखती है।
जानकारी
लेखक का मूल विवरण
Analyze JavaScript heap snapshots (.heapsnapshot files from Chrome, Edge, Node.js, Electron or React Native/Hermes) with memlab to find memory leaks, explain why objects stay in memory, and suggest fixes. Use when the user shares or mentions a heap snapshot, asks why memory or heap size keeps growing, sees an out-of-memory crash, detached DOM elements, a growing cache or listener count, or wants to compare snapshots taken before and after a change. Works through the memlab MCP server tools (memlab_*) or, without MCP, the memlab-cli command from the @memlab/mcp-server npm package.
repo: meta/memlab
लोकप्रियता
- GitHub स्टार
- 5.1k
- रैंकिंग में स्थान
- #15055
- लाइसेंस
- MIT
- अपडेट की गई
- 31/10/2026
कमेंट
- …
इस repository की और skills
memlab-capture-heap-snapshots
5.1kयह आपके एजेंट को ब्राउज़र, Node.js, Electron या React Native से JavaScript heap snapshot लेने में मार्गदर्शन देती है, ताकि आप मेमोरी उपयोग का अध्ययन कर सकें।
memlab-find-web-leaks
5.1kयह आपके एजेंट को एक इंटरैक्शन का स्क्रिप्ट वाला टेस्ट चलाकर और उससे बनी लीक रिपोर्ट पढ़कर वेब पेज में मेमोरी लीक ढूँढने में मदद करती है।
memlab-memory-tests
5.1kयह आपके एजेंट को ऐसे स्वचालित टेस्ट लिखने में मदद करती है जो मेमोरी लीक पकड़ें: Node.js कोड के लिए, या CI में चलने वाले ब्राउज़र फ़्लो के लिए।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।