Automated leak testing
memlab (browser)
Section titled “memlab (browser)”Meta’s tool for scenario-based leak detection.
npx memlab run --scenario ./scenarios/open-modal.jsDefines: navigate → interact → back → repeat → analyze heap diff.
Node soak in CI
Section titled “Node soak in CI”# sketch — run leak script with memory ceiling- name: memory soak run: | timeout 120 node examples/node/01-global-array-fixed.js & PID=$! sleep 90 RSS=$(ps -o rss= -p $PID | tr -d ' ') kill $PID test "$RSS" -lt 300000 # KB thresholdFail CI if fixed script regresses.
Snapshot diff scripts
Section titled “Snapshot diff scripts”Take heap snapshots at start/end of test suite; compare retained constructors (heavy — usually nightly job).
What to automate
Section titled “What to automate”| Test | Catches |
|---|---|
| memlab scenario | SPA navigation leaks |
| Node soak | Server module-scope leaks |
| Listener count assert | emitter.listenerCount() after tests |
Broken process
Section titled “Broken process”“We’ll profile manually before each release.”
Fixed process
Section titled “Fixed process”Leak scenario in CI on every PR touching lifecycle code.