-
Notifications
You must be signed in to change notification settings - Fork 270
Open
Labels
Description
Version
1.45.0
Steps to reproduce
- Clone my repro repo: https://github.com/mu88/Repro_Playwright
- Run
dotnet build
- Run
pwsh Web\bin\Debug\net8.0\playwright.ps1 install
- Run the app (either via IDE or
dotnet run
) - Check the app's log output whether a screenshot is created every 15 s (log message
info: NewScreenshotCreator[0] Screenshot created
) - Attach a memory profiler to the app (e.g. dotMemory)
- Create a first memory dump
- Wait some time, e.g. 15 min
- Create another memory dump
Expected behavior
The app should not use more memory over time (both managed and unmanaged).
Actual behavior
The app uses more memory over time (both managed and unmanaged).
Additional context
I quickly analyzed one memory dump. Without further understanding of what's going on in Playwright internally, I don't want to speculate about the unmanaged memory. For the managed memory, however, I already discovered the following:
- Most of the memory is retained by
StdIOTransport
and some reflection code. StdIOTransport
is instantiated inawait Playwright.CreateAsync()
In the following screenshot, you see the increasing memory footprint over time:
In the next screenshot, you see the dominating types retaining the memory (last memory dump taken):
And last but not least, the following screenshot shows several issues, e.g. duplicate strings, sparse arrays, and leaking event handlers:
Environment
- Operating System: Windows 10, Windows 11, WSL2, Linux (Raspberry Pi)
- CPU: arm64, amd64
- Browser: All
- .NET Version (TFM): [net8.0]
lonix1304NotModified