Skip to content

Automated leak testing

Meta’s tool for scenario-based leak detection.

Terminal window
npx memlab run --scenario ./scenarios/open-modal.js

Defines: navigate → interact → back → repeat → analyze heap diff.

# 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 threshold

Fail CI if fixed script regresses.

Take heap snapshots at start/end of test suite; compare retained constructors (heavy — usually nightly job).

Test Catches
memlab scenario SPA navigation leaks
Node soak Server module-scope leaks
Listener count assert emitter.listenerCount() after tests

“We’ll profile manually before each release.”

Leak scenario in CI on every PR touching lifecycle code.