cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Memory leak in long running single test

Open Konstruktour opened this issue 5 years ago • 58 comments

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

Konstruktour avatar May 08 '19 19:05 Konstruktour