Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve memory management for chromium-based browsers #25462

Merged
merged 103 commits into from
Jan 18, 2023

Conversation

mschile
Copy link
Contributor

@mschile mschile commented Jan 13, 2023

User facing changelog

  • Added new experimentalMemoryManagement flag to improve memory management in Chromium-based browsers.

Additional details

Algorithm:

  • When the test run starts:

    1. set total mem limit for the container/host by reading off cgroup memory limits (if available) otherwise use os.totalmem()
    2. turn on memory profiler
  • On a defined interval (e.g. 1s):

    1. set current mem available for the container/host by reading off cgroup memory usage (if available) otherwise use si.mem().available
    2. set current renderer mem usage
    3. set max avail render mem to minimum of v8 heap size limit and total available mem (current available mem + current renderer mem usage)
    4. calc % of memory used, current renderer mem usage / max avail render mem
  • Before each test:

    1. if any interval exceeded the defined memory threshold, then do a GC prior in between running the next test
  • After the test run ends:

    1. turn off memory profiler

Since the manual GC is run before each test, if a single test consumes enough memory, it is still possible to reach an OOM scenario.

Steps to test

Run a spec that consumes enough memory to cause an OOM error and then turn on the experimental flag and verify the spec now passes.

How has the user experience changed?

Ran the following spec on Chromium 107 in run mode:

describe('memory', () => {
  for (let index = 0; index < 200; index++) {
    it(`test ${index + 1}`, () => {
      cy.visit('https://earth.google.com/web/')
    })
  }
})

Before (OOM crash at test 85):
Screen Shot 2023-01-13 at 12 05 42 PM

After (No OOM crash):
Screen Shot 2023-01-13 at 12 03 06 PM

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?

@mschile mschile marked this pull request as ready for review January 17, 2023 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Out of memory issue after update a browsers to version 104+ (Chrome&Edge)
3 participants