cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Aw Snap Out Of Memory Issue

Open UsmanKarim08 opened this issue 1 year ago • 12 comments

Test code to reproduce

we have 476 teste cases in our project so far when we execute them together browser crash and give us Aw Snap Out Of Memory error it happen when we run bunch of test cases together. But when we run the individually they run good. can you please help us to resolove that issue

Cypress Mode

cypress run

Cypress Version

v12.17.2

Browser Version

v120

Node version

v20.5.1

Operating System

windows 10

Memory Debug Logs

No response

Other

No response

UsmanKarim08 avatar Jan 08 '24 20:01 UsmanKarim08

I have just had the same issue yesterday, as we do many combinations for exploration tests.

Even for a most simplified case it could be reproduced the memory leak:

import { range } from 'lodash-es';

describe('Find Memory Leak', () => {
  range(1, 500).forEach((i) => {
    it('Yeah - ' + i, () => {
      cy.visit('https://google.com');
      cy.get('body').click();
    });
  });
});

After 140 / 500 the memory is already 3 GB (Cypress Helper (Renderer) on mac resource monitor terminal). I set the config: screenshotOnRunFailure: true even to true to make sure it should be empty. Tried with Chrome and Electron as well, with 13.2.0 and 13.6.2 versions as well. It seems doesn't matter if the test fails or is success. I thought the similar issue raised again as https://github.com/cypress-io/cypress/issues/18549, but haven't seen any similarity yet.

Upd:

It even crashed with the following message

<--- Last few GCs --->

[46350:0x148008000]   432069 ms: Mark-Compact (reduce) 2709.6 (3276.9) -> 2708.1 (3243.0) MB, 2659.42 / 0.04 ms  (average mu = 0.107, current mu = 0.022) last resort; GC in old space requested
[46350:0x148008000]   434541 ms: Mark-Compact (reduce) 2708.1 (3243.0) -> 2707.8 (3226.3) MB, 2470.33 / 0.00 ms  (average mu = 0.058, current mu = 0.001) last resort; GC in old space requested


<--- JS stacktrace --->

[46350:0109/153626.318295:ERROR:v8_initializer.cc(753)] V8 javascript OOM (CALL_AND_RETRY_LAST).
We detected that the Electron Renderer process just crashed.

We have failed the current spec but will continue running the next spec.

This can happen for a number of different reasons.

If you're running lots of tests on a memory intense application.
  - Try increasing the CPU/memory on the machine you're running on.
  - Try enabling experimentalMemoryManagement in your config file.
  - Try lowering numTestsKeptInMemory in your config file during 'cypress open'.

You can learn more here:

https://on.cypress.io/renderer-process-crashed

Upd: I didn't mention but all those configs adjustment didn't help, settings keptInMemory to 5, and run in chrome with MemoryManagement resulted the same issue.

Greegko avatar Jan 09 '24 14:01 Greegko

I've been experiencing the same thing with our suite, it's been a problem for over a year. I've been working on finding a workaround but haven't been able to yet. It's definitely an issue with Cypress.

banjahman avatar Jan 09 '24 17:01 banjahman

I too agree with this, running many test cases at once is throwing this error! I tried with below configs also, still the same error numTestsKeptInMemory: 0, experimentalMemoryManagement: true,

akshaygupta5233 avatar Jan 10 '24 19:01 akshaygupta5233

at this point imo the best solution is to migrate to playwright like the rest of the world. cypress is just shrugging issues under the rug and calling it a day. just search for all the OOM issues reported before and you'll have pretty good idea what will happen to this one.

ivanharalampiev avatar Jan 30 '24 16:01 ivanharalampiev

Same for me. No fix.

bensouth avatar Feb 09 '24 16:02 bensouth

at this point imo the best solution is to migrate to playwright like the rest of the world. cypress is just shrugging issues under the rug and calling it a day. just search for all the OOM issues reported before and you'll have pretty good idea what will happen to this one.

I recently starting porting our codebase over to playwright. It's very similar in syntax, so the migration is pretty easy. Playwright runs faster, better, more reliably, has more features, and costs far less. At this point sticking with Cypress is shooting yourself in the foot. I tried to give them a chance to fix the show stopping issues but all that ever gets done are closed issues without any resolution.

banjahman avatar Feb 09 '24 16:02 banjahman

Same thing for me - never was an issue with Electron, but here we are

Jacek-fstack avatar Mar 19 '24 12:03 Jacek-fstack

Any update on this? Workaround? It is a blocker for executing more tests on CI as memory is not released between tests.

LukasLewandowski avatar Mar 25 '24 12:03 LukasLewandowski

Any updates @jennifer-shehane ?

Jacek-fstack avatar Apr 02 '24 12:04 Jacek-fstack

@banjahman how long did it take you to migrate to Playwright? How many tests did you have?

Jacek-fstack avatar Apr 02 '24 14:04 Jacek-fstack

For me, changing the Cypress version from 3.11.0 to 3.6.0 helped. Might work as a workaround for some. I also have experimentalMemoryManagement enabled.

stepanroznik avatar Jun 18 '24 07:06 stepanroznik

@stepanroznik It'd be great to have an example for us to reproduce this. We/d be very interested in tracking down a performance regression.

jennifer-shehane avatar Jun 25 '24 13:06 jennifer-shehane

This problem has been bothering me for two years now

maoyu-test avatar Jul 10 '24 07:07 maoyu-test

@stepanroznik It'd be great to have an example for us to reproduce this. We/d be very interested in tracking down a performance regression.

Hey, as mentioned the second comment even the most basic tests crash: https://github.com/cypress-io/cypress/issues/28662#issuecomment-1883163363

Greegko avatar Jul 10 '24 09:07 Greegko

Going to close this as a duplicate of https://github.com/cypress-io/cypress/issues/27415#issuecomment-2258782755

jennifer-shehane avatar Jul 30 '24 17:07 jennifer-shehane