https://cypress.io logo
JavaScript heap out of memory
# i-need-help
l
My client tests are crashing cause heap out of memory. here is the message
Copy code
Running:  registration/registration.cy.ts                                               (26 of 38)

<--- Last few GCs --->

[1842:0x7fc7b8008000]   569883 ms: Mark-sweep 4051.8 (4143.5) -> 4036.2 (4144.0) MB, 1933.5 / 0.0 ms  (average mu = 0.119, current mu = 0.015) allocation failure scavenge might not succeed
[1842:0x7fc7b8008000]   571794 ms: Mark-sweep 4045.7 (4144.0) -> 4036.2 (4144.0) MB, 1536.6 / 0.0 ms  (average mu = 0.155, current mu = 0.196) allocation failure GC in old space requested


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x101b7f5f5 node::Abort() (.cold.1) [path/to/node/v16.18.1]
 2: 0x100874f49 node::Abort() [path/to/node/v16.18.1]
 3: 0x10087512e node::OOMErrorHandler(char const*, bool) [path/to/node/v16.18.1]
 4: 0x1009ec3f0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [path/to/node/v16.18.1]
 5: 0x1009ec3b3 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [path/to/node/v16.18.1]
 6: 0x100b90095 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [path/to/node/v16.18.1]
 7: 0x100b940dd v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [path/to/node/v16.18.1]
 8: 0x100b909bd v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [path/to/node/v16.18.1]
...
Documentation says : ## Memory * 4GB minimum, 8GB+ for longer test runs https://docs.cypress.io/guides/getting-started/installing-cypress#Memory What does longer test run means? I see a warning:
Copy code
Trace: The new-window event is deprecated and will be removed. Please use contents.setWindowOpenHandler() instead.
    at Object.log (node:electron/js2c/browser_init:225:603)
Who can help? Cypress 12.4.1 npm 16.18.1
Somehow this issue disappeared. Strange. Have no idea why or how....
f
This often occurs when the application is allocating too much memory, causing it to exceed the limit set by Node.js. It's possible that the application being tested has memory leaks or inefficient memory usage, causing the Node.js process to consume more memory than it should. It's also possible that the Cypress tests themselves are causing excessive memory usage, for example, by making many API requests or performing complex DOM manipulations. To determine the root cause, you could try running the tests with different parts of the application under test disabled, or by breaking down the tests into smaller parts and running them individually.
b
A few things you can try: Increasing your Max Memory: https://support.google.com/chrome/thread/174889666/increasing-the-memory-limit-on-chrome-v104?hl=en-GB Disable the
experimentalSessionAndOrigin
in Cypress version 12. You no longer need to have the experimental flag for version 12+. Increase your node memory --max-old-space-size: https://stackoverflow.com/questions/48387040/how-do-i-determine-the-correct-max-old-space-size-for-node-js If the issue continues: Try using a different browser that isn't chromium-based, like Edge: https://docs.cypress.io/guides/guides/launching-browsers#Browser-versions-supported Decrease your numTestsKeepInMemory to lower your memory consumption: https://docs.cypress.io/guides/references/configuration#Global Cypress 12.4 or higher a new feature was released experimentalMemoryManagement to improve memory management in Chromium-based browsers.
12 Views