cypress: Memory leak in long running single test
Current behavior:
Currently if a test runs the same actions repetitively over a long period of time, the memory of the cypress process increases until it crashes. (headless mode, video off, numTestsKeptInMemory 0) The sample to reproduce runs 15 minutes increasing the memory ~300MB. (the longer the run the more memory is used…)
Desired behavior:
Performance tests should be possible with cypress, without increasing memory and crashing.
Steps to reproduce: (app code and test code)
Config cypress.json
{
"baseUrl": "http://localhost:8080/",
"defaultCommandTimeout": 60000,
"viewportWidth": 1280,
"viewportHeight": 720,
"numTestsKeptInMemory": 0,
"video": false
}
Cypress test
describe('memory dummy test', () => {
const endTime = Date.now() + 60000 * 15;
before('visit', () => {
cy.visit('/memory-test.html');
});
it('should test', () => {
const test = () => {
cy.get('#testinput').clear().type('hello world');
cy.wait(2000);
cy.then(() => {
if (Date.now() < endTime) test();
});
};
test();
});
});
Simple static html site
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<input id="testinput">
</body>
</html>
Versions
Cypress 3.2.0 / 3.5.0 / 3.6.0 Windows 10
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 23
- Comments: 57 (9 by maintainers)
Any update on memory leak
same problem 9.6.1
8.5.0 as well…
@Oliboy50 not really, i still have it in 6.0.0
@jennifer-shehane if you want another easily reproductible example => I guess I’m experiencing something similar in this project on cypress
4.10.0it runs a single test which is pretty fast at the beginning and starts to be really slow after ~50 seconds of execution
I tried to use
"numTestsKeptInMemory": 0cypress configuration but it didn’t help at all 🤷if you want to try it out, please install
node v12.xand run the following commands:Cypress GUI will pop up and you’ll be able to run the test I’m talking about
hope it will help (I’d love to have a faster test, one which does not make my computer burn ❤️)
Hi @nagash77 , I have created reproducible example of this issue: https://github.com/StefanTegeltija/memory-leak-in-long-running-single-test, sorry I haven’t used for of Cypres Test Tiny but it should not be hard to run my example. In order to run tests you just need to:
any updates ??
Error code: Out of Memory
Check https://github.com/cypress-io/cypress/discussions/25557
I’v also added env var CYPRESS_NO_COMMAND_LOG=1 on our pipeline. Not much added value having the command log for remote runs.
I’ve added some memory graphs on twitter: https://twitter.com/op_kris/status/1636675020180058112?s=46&t=DPClh6K4rCQElpP_CUCryg showing the difference between the usage of the command log or not.
Any updates on this from Cypress?
@Oliboy50 - Yea that looks good to me, for reference this is what we have in our
plugins/index.js:You also may need to increase or decrease the
max_old_space_sizesetting, 1500 worked for us but maybe you need more or less memory. I would try: 500, 1000, 2000, and 10000 and see if any of those workIf that does not work, I suggest trying out this logging package so you can see the exact error you are getting in the terminal when you run your pipeline: https://github.com/flotwig/cypress-log-to-output (for us, Cypress was swallowing the console errors)
You will need to use the
"chromeWebSecurity": false,setting in yourcypress/environments/cypress.{env}.jsonfiles, this logging package seems to make the browser ignore that flag for some reasonNote that we are on an older version of Cypress and older image, and we are running this on Gitlab CI: package.json:
"cypress": "^4.12.1".gitlab-ci.yml (image):name: cypress/included:4.9.0Closing this issue as duplicate because I’m very confident this is describing the same behavior as https://github.com/cypress-io/cypress/issues/4104