cypress out of memory on large test runs
Fixes Cypress OOM crashes on large suites: memory flags, splitting, and leaks. Use when the Cypress process dies with out-of-memory. Not for jest heap OOM (separate skill).
TL;DR
Cypress runs the browser and the test runner in one process tree, and large suites exhaust the heap. Raise the Node memory limit, split the run into smaller chunks, and look for specs that leak memory across tests.
Error
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memorySteps
- Confirm it is Cypress and not the app: the crash message names the Cypress process, and small specs pass. Expected: you rule out the application.
- Raise the memory limit for the Cypress process:
NODE_OPTIONS=--max-old-space-size=4096 npx cypress run. Expected: the run gets further before any crash. - Split the suite: run specs in groups (
--spec "cypress/e2e/a/**", thenb/**). Expected: each chunk fits comfortably in memory. - Find leaking specs: run each spec file alone and watch memory; a spec whose memory never drops between tests is the culprit. Expected: one or two specs stand out.
- Fix the leak: usually unclosed intercepts, huge fixtures loaded per test, or DOM retained by aliases. Expected: the spec's memory returns to baseline after each test.
When to use
JavaScript heap out of memorynaming the Cypress or Electron process.- Suites with hundreds of specs or very large fixtures.
When not to use
- Jest heap OOM (different process model; see that skill).
- The app under test runs out of memory (check the app's own logs).
Tool compatibility
- Cypress 10 through 14;
NODE_OPTIONSrespected by the Cypress CLI.
Variant phrasings
Cypress crashed with SIGKILL in CI
CI OOM-killer, same root cause; check runner memory limits, not just Node flags.
Allocation failed during cypress run
The long form of the heap error; the fix is identical.
Why it happens
Each spec file loads fixtures, plugins, and support files into the same long-lived process. Memory grows across specs and the default heap limit is too small for big suites.
Edge cases
- Raising the heap without splitting just delays the crash on truly huge suites.
numTestsKeptInMemorycontrols how many test snapshots Cypress retains; lowering it cuts memory a lot.- Videos held in memory during the run also count; disabling video for passes helps.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_6nusfTqtHsSk4fIXUiawdA
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.