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

[Problem/Bug]: Memory leak? WebView2 and parent window not released after close #4286

Open
cuiliang opened this issue Jan 10, 2024 · 4 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@cuiliang
Copy link

cuiliang commented Jan 10, 2024

What happened?

Using the smaple application: https://github.com/MicrosoftEdge/WebView2Samples/tree/main/SampleApps/WebView2WpfBrowser

  1. start the application
  2. New window mutliple times
    image
  3. Close the windows, and leave one to keep application running.
  4. Use dotmemory, attach to the process, and take snapshots.
  5. WebView2 and MainWindow objects never got GC collected.

image

image

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

120.0.2210.121

SDK Version

1.0.2210.55

Framework

WPF

Operating System

Windows 11

OS Version

No response

Repro steps

See issue description.

Repros in Edge Browser

No

Regression

No, this never worked

Last working version (if regression)

No response

AB#48526819

@cuiliang cuiliang added the bug Something isn't working label Jan 10, 2024
@cuiliang cuiliang changed the title [Problem/Bug]: Memory leak? WebView2 and parent window not released after closed [Problem/Bug]: Memory leak? WebView2 and parent window not released after close Jan 10, 2024
@cuiliang
Copy link
Author

This is another test, after window closed more than 10 minutes and Force GC in dotMemory, objects still not GC collected.
image

@vbryh-msft vbryh-msft added the tracked We are tracking this work internally. label Jan 17, 2024
@vbryh-msft
Copy link
Contributor

@cuiliang thank you for reporting the issue. I have created work item to take time to look into it.

@cuiliang
Copy link
Author

@vbryh-msft Besides, if the HostObject used in AddHostObjectToScript() hode a reference of host window, there will be another
referenct path live after window closed.

@fabiorocha fabiorocha assigned monica-ch and unassigned vbryh-msft Jan 22, 2024
@monica-ch
Copy link
Contributor

@cuiliang We've fixed the issue in Edge canary 126.0.2536.0+. Please test and let us if WV2 objects are still leaking.

Also, there is a small issue in WebView2WpfBrowser where the code isn't calling webView.Dispose() upon Close WebView. We'll soon push that sample app fix to our public repo but please call WV2 dispose for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

3 participants