memlab-capture-heap-snapshots
यह क्या करती है
यह समझाती है कि एक snapshot कैसे लें, या दोहराए गए कामों में क्या बढ़ता है यह देखने के लिए snapshots की श्रृंखला कैसे लें। यह उन डेवलपर्स के लिए है जिन्हें लीक ढूँढने के लिए मेमोरी का डेटा चाहिए।
कब इस्तेमाल करें
- ✓जब आपको ब्राउज़र टैब या Node.js प्रक्रिया का heap snapshot चाहिए।
- ✓जब आप देखना चाहते हैं कि किसी इंटरैक्शन को दोहराने के बाद मेमोरी बढ़ती है या नहीं।
- ✓जब आपकी प्रक्रिया मेमोरी खत्म होने के करीब है और आपको उसका डंप चाहिए।
Skill का लिंक
https://github.com/meta/memlab/blob/main/plugins/memlab/skills/memlab-capture-heap-snapshots/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी वेब ऐप के सेटिंग्स डायलॉग को पाँच बार खोलने से पहले और बाद में snapshot लीजिए, ताकि मैं उनकी तुलना कर सकूँ।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
आपका एजेंट एक snapshot या श्रृंखला चुनता है, कैप्चर के लिए ब्राउज़र या प्रक्रिया सेट करता है, और फ़ाइलें सहेजता है। हर snapshot बीच में पेज रीलोड किए बिना लिया जाता है, ताकि बढ़त मापी जा सके।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Capture JavaScript heap snapshots
A heap snapshot is a full dump of a JavaScript heap: every object, the
references between them, and their sizes. memlab, Chrome DevTools and the
memlab MCP server all read the same .heapsnapshot format.
Decide what to capture first
- "What is using memory?" One snapshot, taken when memory is high.
- "Is something leaking?" Several snapshots from the same page or process: no reload and no restart in between, with the suspect interaction repeated between captures. A single snapshot can't show growth.
- Take snapshots from a build that matches the problem. Development builds (React development mode, hot reload, source-map tooling) hold extra memory a production build doesn't.
Browser (Chrome, Edge)
By hand: DevTools → Memory → Heap snapshot → Take snapshot, then right-click the snapshot → Save.... DevTools runs garbage collection before each snapshot. Use a profile without extensions (or a guest window): extensions add their own objects to the page's heap.
From an agent, with the memlab MCP server: start the browser with
--remote-debugging-port=9222 --user-data-dir=/tmp/chrome-memlab, then call
memlab_capture with out_dir and a label. Chrome 136 and later ignore
--remote-debugging-port on the default profile, so the separate
--user-data-dir is required; a fresh profile also has no extensions. It also captures the page's dedicated workers, which a page snapshot
never includes. list_targets: true lists the pages it can attach to, and
url_filter picks one. A saved capture can later be referred to as
checkpoint:<label> wherever a snapshot path is accepted.
From Puppeteer or Playwright test code (Chromium only): use a CDP session. See references/capture-code.md for a copy-paste helper that runs garbage collection and streams the snapshot to a file.
Node.js
- From code:
require('v8').writeHeapSnapshot()writes a snapshot into the current directory and returns the file name. Pass a path to choose it. - From outside, on demand: start with
node --heapsnapshot-signal=SIGUSR2 app.js, then runkill -USR2 <pid>each time you want a snapshot. - Just before running out of memory: start with
node --heapsnapshot-near-heap-limit=3 app.js(Node.js 14.18+/15.1+). It writes up to 3 snapshots as the heap approaches its limit. - Interactively: start with
node --inspect app.js, openchrome://inspect, and use the Memory tab as in a browser. - In a memlab test:
dumpNodeHeapSnapshot()from@memlab/corewrites a snapshot to a temp folder and returns its path.
Writing a snapshot pauses the process and can temporarily need about as much memory again as the heap itself. Don't take one from a production server that is already close to its memory limit unless you can afford the pause.
Electron
- Renderer processes: open DevTools in the window and use the Memory tab.
- Main process: it is Node.js, so use
v8.writeHeapSnapshot(), or start the app with--inspectand attach fromchrome://inspect.
React Native (Hermes)
Open the debugger for the app (React Native DevTools) and take a heap snapshot from its Memory panel. memlab reads Hermes snapshots too.
memlab itself
memlab run --scenario <file> and memlab snapshot --scenario <file> drive
a page in Chromium and save s1.heapsnapshot (baseline), s2.heapsnapshot
(after the action) and s3.heapsnapshot (after undoing it) under
$(memlab get-default-work-dir)/data/cur/. See the memlab-find-web-leaks
skill for writing the scenario.
Capture a series that shows growth
- Load the page or start the process. Run the interaction a few times to warm up caches and lazy-loaded code.
- Take snapshot 0.
- Repeat the interaction N times (for example 10), returning to the starting state each time. Take the next snapshot. Do this 3–5 times.
- Optional but valuable: leave the app idle for a minute, run GC, and take a final "settle" snapshot. Growth that disappears here was work in flight, not a leak.
- Name the files in order and record the cycle count, for example
rung_00_c000.heapsnapshot,rung_01_c010.heapsnapshot, ... memlab's series tools read the cycle count from that naming.
Then analyze them with memlab_sequence_analysis or memlab_leak_report
(paths in order), or diff two of them with memlab_diff_snapshots. The
memlab-analyze-heap-snapshot skill
अक्सर पूछे जाने वाले सवाल
कई snapshots क्यों लें?
एक snapshot दिखाता है कि मेमोरी में क्या है, पर बढ़त तभी दिखती है जब एक ही सेशन में लिए गए snapshots की तुलना हो।
किस बिल्ड का snapshot लेना चाहिए?
वह बिल्ड जो समस्या से मेल खाता हो, क्योंकि डेवलपमेंट बिल्ड में अतिरिक्त मेमोरी होती है जो प्रोडक्शन बिल्ड में नहीं होती।
क्या मैं Chrome में snapshot हाथ से ले सकता हूँ?
हाँ। स्किल में DevTools Memory टैब से snapshot लेने और सहेजने के चरण समझाए गए हैं।
जानकारी
लेखक का मूल विवरण
Capture JavaScript heap snapshots (.heapsnapshot files) for memory analysis from Chrome or Edge, Puppeteer, Playwright, Node.js, Electron or React Native (Hermes), including a series of snapshots that shows what grows over repeated interactions. Use when the user needs a heap snapshot, a heap dump of a Node.js process or one taken near out-of-memory, wants to measure memory growth or a suspected leak, or asks how to take snapshots in a test so memlab can analyze them.
repo: meta/memlab
लोकप्रियता
- GitHub स्टार
- 5.1k
- रैंकिंग में स्थान
- #15056
- लाइसेंस
- MIT
- अपडेट की गई
- 31/10/2026
कमेंट
- …
इस repository की और skills
memlab-analyze-heap-snapshot
5.1kयह आपके एजेंट को heap snapshot पढ़कर JavaScript ऐप में मेमोरी लीक ढूँढने और समझाने में मदद करती है कि कौन-सी चीज़ें ऑब्जेक्ट को ज़िंदा रखती हैं।
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 खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।