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

Can not release webview2,memory leak #4412

Open
eijjxx opened this issue Mar 7, 2024 · 0 comments
Open

Can not release webview2,memory leak #4412

eijjxx opened this issue Mar 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@eijjxx
Copy link

eijjxx commented Mar 7, 2024

What happened?

use webview2 in a usercontrol
i can't release the webview2 when the usercontrol closed(remove from virtualtree)

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

122.0.2365.66

SDK Version

1.0.2365.46

Framework

WPF

Operating System

Windows 10

OS Version

22621.1992

Repro steps

minium code:

        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
        }

        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                var uc = new CCTest();
                var wb = new WebView2();
                uc.Content = wb;
                wb.Source = new Uri("https://www.baidu.com");
                g2.Children.Add(uc);
            }
            Console.WriteLine(CCTest.count);
            await Task.Delay(100);
            g2.Children.Clear();
            for (int i = 0; i < 100; i++)
            {
                GC.Collect();
                await Task.Delay(10);
            }
            Console.WriteLine(CCTest.count);
        }

      public class CCTest : ContentControl
      {
          public static int count = 0;
  
          public CCTest()
          {
              count++;
          }
  
          ~CCTest()
          {
              count--;
          }
      }

count is 10

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@eijjxx eijjxx added the bug Something isn't working label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant