-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Current behavior
While cy.get() retries to find an element , the memory usage of the tab shoots up quickly
See video https://youtu.be/N5jtyBdd05Q
Desired behavior
Memory usage should not increase this quickly
Test code to reproduce
describe('Memory issue', () => {
it('Simple memory test', () => {
cy.visit('https://www.androidpolice.com')
cy.get('.garbageId')
})
})
Cypress Version
5.1.0 and latest 8.6.0
Other
Initially I found this issue while testing my company's website, then I found that it is easily reproducible with other websites as well
Pre-requisistes
- numTestsKeptInMemory has to be set to 1 or higher
- set defaultCommandTimeout to a higher value (eg. 50000) so there's more time for the memory to increase
Steps to reproduce
- Visit a website (eg. https://www.androidpolice.com)
- Use cy.get() to find an non-existent element
As you can see in the video linked above, the memory usage starts shooting up when Cypress is trying to find the element.
When you re-run the test without closing the tab, the memory doesn't reset and keeps adding up. Eventually when the usage reaches 4GB, the tab crashes with the "Aw snap" message.
This issue is a lot more apparent if the test is longer with more steps, which can put the memory usage close to the ceiling of 4GB.
So far the reliable workaround is to set numTestsKeptInMemory to 0, which stops the memory creep altogether.
Very occasionally I can observe the garbage collection kicking in and reducing the memory usage, however the cy.get() still rapidly increases the memory usage after