memlab-capture-heap-snapshots
Was er macht
Dieser Skill erklärt, wie man einen einzelnen Snapshot oder eine Reihe von Snapshots erstellt, die zeigt, was bei wiederholten Aktionen wächst. Er ist für Entwickler gedacht, die Speicherdaten brauchen, um ein Leck aufzuspüren.
Wann du ihn nutzt
- ✓Wenn du einen Heap-Snapshot eines Browser-Tabs oder eines Node.js-Prozesses brauchst.
- ✓Wenn du sehen willst, ob der Speicher nach einer wiederholten Interaktion wächst.
- ✓Wenn dein Prozess fast keinen Speicher mehr hat und du einen Dump brauchst.
Link zum Skill
https://github.com/meta/memlab/blob/main/plugins/memlab/skills/memlab-capture-heap-snapshots/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Erstelle Heap-Snapshots meiner Web-App vor und nach fünfmaligem Öffnen des Einstellungsdialogs, damit ich sie vergleichen kann.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Agent wählt einen einzelnen Snapshot oder eine Reihe, richtet einen Browser oder Prozess für die Aufnahme ein und speichert die Dateien. Er nimmt jeden Snapshot ohne Neuladen dazwischen auf, damit das Wachstum gemessen werden kann.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von 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
Häufige Fragen
Warum mehrere Snapshots machen?
Ein Snapshot zeigt, was im Speicher liegt, aber Wachstum zeigt sich erst beim Vergleich von Snapshots aus derselben Sitzung.
Welchen Build sollte ich aufnehmen?
Einen Build, der zum Problem passt, denn Entwicklungs-Builds halten zusätzlichen Speicher, den Produktions-Builds nicht halten.
Kann ich in Chrome von Hand einen Snapshot erstellen?
Ja. Der Skill erklärt die Schritte im DevTools-Reiter Memory zum Erstellen und Speichern eines Snapshots.
Details
Originalbeschreibung des Autors
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
Beliebtheit
- GitHub-Sterne
- 5.1k
- Platz im Ranking
- #15056
- Lizenz
- MIT
- Aktualisiert
- 31.10.2026
Kommentare
- …
Weitere Skills aus diesem Repository
memlab-analyze-heap-snapshot
5.1kHilft deinem Agenten, Speicherlecks in einer JavaScript-App zu finden, indem er einen Heap-Snapshot analysiert und erklärt, was Objekte am Leben hält.
memlab-find-web-leaks
5.1kHilft deinem Agenten, Speicherlecks auf einer Webseite zu finden, indem er eine skriptgesteuerte Prüfung einer Interaktion ausführt und die erzeugten Leck-Berichte liest.
memlab-memory-tests
5.1kHilft deinem Agenten, automatisierte Tests zu schreiben, die Speicherlecks abfangen, für Node.js-Code oder für Browser-Abläufe in der kontinuierlichen Integration.
Ähnliche Skills
diffs
394kLässt deinen Agenten einen echten, teilbaren Diff seiner Änderungen als Viewer-Link oder Bilddatei erstellen, statt einer handgeschriebenen Zusammenfassung.
coding-agent
394kHilft deinem Agenten, eine größere Programmieraufgabe als Hintergrund-Worker an Codex, Claude Code oder OpenCode zu übergeben und danach den Fortschritt zu prüfen.
gh-issues
394kHilft deinem Agenten, GitHub-Issues zu finden, die zu bearbeitenden auszuwählen und Pull Requests mit Korrekturen zu öffnen, einschließlich der Nacharbeit an Review-Kommentaren.