question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak in long running single test

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:20
  • Comments:33 (7 by maintainers)

github_iconTop GitHub Comments

8reactions
ronwongsk661commented, Jan 29, 2021

Any update on memory leak

5reactions
JaLe29commented, Jun 1, 2022

same problem 9.6.1

import { links } from './links'; // 500 items

context('Full version tests', () => {
	beforeEach(() => {
		cy.login();
	});

	links.forEach(link => {
		it(`should load page ${link}`, () => {
			cy.visit(link); 
			cy.wait(5000);
			cy.hasNotErrorMessage();
		});
	});
});

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Finding the cause of a memory leak in Jest tests
Memory leaks can be nasty and pretty hard to find. We found that the hard way. We should always make sure to clean...
Read more >
Your Jest Tests are Leaking Memory
That is, until you add one more test and suddenly the suite comes apart. In this article, we'll walk through why it's so...
Read more >
Memory leak detection - How to find, eliminate, and avoid
The simplest way to detect a memory leak is also the way you're most likely to find one: running out of memory. That's...
Read more >
Memory Leak Testing in Continuous Integration Systems
While developers may routinely run their own memory tests on the code they are actively developing, memory testing later in the development ...
Read more >
Memory leak detection while running unit tests - Stack Overflow
To obtain this sort of information, we override new/delete and malloc/free, providing our own heap implementations that store stacktraces on allocation and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found