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

[Bug]: Memory problem #33086

Closed
FKlindt opened this issue Oct 14, 2024 · 12 comments
Closed

[Bug]: Memory problem #33086

FKlindt opened this issue Oct 14, 2024 · 12 comments
Assignees
Labels

Comments

@FKlindt
Copy link

FKlindt commented Oct 14, 2024

Version

Version 1.48.0

Steps to reproduce

Set up a new Playwright project.

Run the tests using npx playwright test --ui.

Observe the memory usage during test execution, especially on a machine with limited resources (e.g., 20GB RAM).

You should see the memory usage increase rapidly, especially if multiple tests are queued, leading to an "out of memory" error.

Image
Image

Expected behavior

The tests should execute normally without exhausting available memory. Chromium instances should close automatically after each test in UI mode, similar to non-UI mode, without building up in memory.

Actual behavior

Running tests in UI mode with npx playwright test --ui results in excessive memory usage. Chromium instances remain open after test execution, which causes the system to run out of memory (particularly noticeable on a machine with limited memory). This issue does not occur when running tests without UI mode, where Chromium instances close correctly after each test.

Additional context

The issue is only observed in UI mode. Running the same tests without UI mode does not cause high memory usage, and Chromium instances close as expected after each test.
my config.txt

Environment

System:
OS: Windows Server 2016 10.0.14393
CPU: (4) x64 Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz
Memory: 13.43 GB / 20.00 GB
Binaries:
Node: 22.3.0 - ~\AppData\Local\nodejs\node.EXE
npm: 10.8.1 - ~\AppData\Local\nodejs\npm.CMD
IDEs:
VSCode: 1.90.2 - C:\Program Files\Microsoft VS Code\bin\code.CMD
npmPackages:
@playwright/test: ^1.48.0 => 1.48.0
playwright: ^1.48.0 => 1.48.0
playwright-chromium: ^1.48.0 => 1.48.0
playwright-firefox: ^1.48.0 => 1.48.0

@FKlindt FKlindt changed the title [Bug]: [Bug]: Memory problem Oct 14, 2024
@dgozman
Copy link
Contributor

dgozman commented Oct 14, 2024

@FKlindt I tried to reproduce on Windows 11 Enterprise with @playwright/test version 1.48.0, and the number of chrome.exe processes stays the same for me. Most likely, there is an issue on your particular computer, but I'm not sure we'll be able to help with that. I guess you could share a full repro with us, and we can try to reproduce locally, but the chances are not very high.

@FKlindt
Copy link
Author

FKlindt commented Oct 15, 2024

@dgozman Thanks for checking! Given that the issue seems specific to my environment, would you recommend any particular steps I could take to troubleshoot further? I'd be happy to share a full repro if that helps. Do you suggest anything else I can try to isolate the problem before submitting the repro?

@dgozman
Copy link
Contributor

dgozman commented Oct 15, 2024

@FKlindt Perhaps try running the UI mode with DEBUG=pw:browser, click the "Toggle output" button in the top toolbar and see the browser logs there. Maybe that will tell us what's going on.

@louwsph
Copy link

louwsph commented Oct 16, 2024

Just in support of the author I am facing the same issue, it started after upgrading to 1.48.0. I've been using the tool for over a year on the same machine/OS and never observed the UI crash with 'out of memory' previously, it's occurring after running just 2 or 3 larger e2e tests in UI mode.

As far as I can see there is no increase in the number of chrome processes however memory usage on processes does seem to have increased compared with previous playwright versions for the same tests.

No idea if this will be of any value but here is a simple test I used to compare on a clean install of npx init playwright@latest using only 'Desktop Firefox' -

for (let index = 1; index <= 5; index++) {
  test(`get started link ${index}`, async ({ page }) => {
    await page.goto('https://playwright.dev/');
    await page.getByRole('link', { name: 'Get started' }).click();
    await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
    await page.getByRole('link', { name: 'Release notes' }).click();
    await expect(page.getByRole('heading', { name: 'Version 1.46' })).toBeVisible();
    await page.getByRole('link', { name: 'Locators', exact: true }).click();
    await expect(page.getByRole('heading', { name: 'Locating elements' })).toBeVisible();
  });
}

This doesn't push it to a crash but my actual tests when it fails are far heavier and longer running.

On 1.48.0 -
(Spawned 8 Chromium processes upon launching UI)

Action Total memory usage ~15 seconds after action
npx playwright test --ui 138mb
Run 1st test 321mb
Run 2nd test 487mb
Run 3rd test 565mb
Run 4th test 775mb
Run 5th test 875mb

On 1.45.3 -
(Spawned 9 Chromium processes upon launching UI)

Action Total memory usage ~15 seconds after action
npx playwright test --ui 174mb
Run 1st test 318mb
Run 2nd test 376mb
Run 3rd test 430mb
Run 4th test 484mb
Run 5th test 520mb

There is clearly freeing of memory happening after the test finishes but it seems like the amount freed has reduced so maybe that is contributing to the issue?

I could not see any difference that stood out comparing the output between versions with DEBUG=pw:browser enabled.

@FKlindt
Copy link
Author

FKlindt commented Oct 16, 2024

I've also noticed that the memory usage ramps up significantly with each test, much like your example. For me, running multiple UI tests results in similar behavior—memory usage climbs test by test until the system crashes, even though this didn't happen in earlier versions like 1.45.3.

It looks like this could be related to how memory is being freed or managed between tests in 1.48.0. I’ll keep monitoring and try running tests with different configurations, but it definitely feels like something changed with this version. Thanks for sharing your comparison—it helps confirm this issue!

@AndyGBC
Copy link

AndyGBC commented Oct 16, 2024

Also seeing 'out of memory' problems running a long running test since upgrading to 1.48.0. Rolled back to 1.47.2 and all OK again. I was just running from command line, so UI mode not in use here. Will try and find a repro....

@dgozman dgozman self-assigned this Oct 17, 2024
@dgozman dgozman added the v1.49 label Oct 17, 2024
@reager
Copy link

reager commented Oct 18, 2024

Also facing this issue since upgrading this morning.

@dgozman
Copy link
Contributor

dgozman commented Oct 23, 2024

Should be fixed by linked PRs.

@notngan
Copy link

notngan commented Oct 28, 2024

I've upgraded @playwright/test to v1.48.2 but the memory issue still remains.

Environment
System:
OS: macOS Sonoma 14.7
Chip: Apple M1 Pro
Memory: 14.84 GB / 16 GB
Binaries:
Node: 16.10
pnpm: 7.33.6
IDEs:
WebStorm 2024.2.4
npmPackages:
@playwright/test: ^1.48.2 => 1.48.2

@ssougnez
Copy link

I'm having the exact same behavior with the version 1.49 on a windows 2022 build server.
I reverted to version 1.47 and it went fine.

@nbaldzhiev
Copy link

I am on 1.49.1, intel MacBook Pro 2019, and using the VSCode's Playwright extension in browser mode instantly causes the CPU to peak. From the activity monitor, I can see that the Chromium processes drain it. So, it could be a matter of this new Chromium version, but my regular Chrome is updated as well, so I am more inclined to think it's Playwright/VSCode's Playwright extension.

@FKlindt
Copy link
Author

FKlindt commented Jan 27, 2025

Yup, I'm facing this issue. It only happens when I'm in the UI, so I can 'live' with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants