Skip to content

Bug: Memory Leak with watch mode --watch=true #4131

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

Closed
mxschmitt opened this issue Apr 8, 2025 · 3 comments
Closed

Bug: Memory Leak with watch mode --watch=true #4131

mxschmitt opened this issue Apr 8, 2025 · 3 comments

Comments

@mxschmitt
Copy link

mxschmitt commented Apr 8, 2025

Reproduction:

  1. git clone https://github.com/microsoft/playwright && cd playwright
  2. npm ci
  3. npx esbuild --log-level=verbose "packages/playwright-core/src/**/*.ts" --outdir=packages/playwright-core/lib --sourcemap=linked --watch=true --platform=node --format=cjs
  4. Go to packages/playwright-core/src/client/page.ts and modify the file header 20 times, between each time save the file and look at the memory consumption.

This can be used as well:

import fs from "fs"
for (let i = 0; i < 100; i++) {
  fs.appendFileSync("packages/playwright-core/src/client/page.ts", "\n")
  await new Promise((resolve) => setTimeout(resolve, 50))
}

and aborted after a few seconds.

Expected: It stays around 50-200 MB
Actual: It grows up to 10-40 GB

Version: 0.25.0 - also tested with 0.25.2

I was able to reproduce on macOS and Linux (Ubuntu amd64).

@mxschmitt
Copy link
Author

Investigation:

  • We are doing --watch=true
  • Internally if --watch is not passed, GC is disabled as per here:
  • Changing it from --watch=true to --watch fixes it

@mxschmitt

This comment has been minimized.

@mxschmitt mxschmitt changed the title Bug: Memory Leak with watch mode Bug: Memory Leak with watch mode --watch=true Apr 8, 2025
@evanw
Copy link
Owner

evanw commented Apr 22, 2025

Thanks for figuring this out, and for the PR. Quite a dumb bug. I'll include the fix for this in the next release.

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 a pull request may close this issue.

2 participants