Memory leak when use x:Bind in winUI3
See original GitHub issueDescribe the bug
Hi, BlankPage.Xaml code:
<Window>
<Grid>
<Button Click="{x:Bind click_event}" />
</Grid>
</Window
BlankPage.xaml.cs code:
private void click_event(object sender, RoutedEventArgs e)
{
int a = 1;
}
~BlankPage1()
{
int a = 1;
}
From main window, I open BlankPage window and close it:
private ButtonClick()
{
var aa = new BlankPage1();
aa.Activate();
aa.Close();
aa = null;
GC.Collect();
}
However, BlankPage object doesn’t released (doesn’t run into ~BlankPage function). And if you continue click to open and close the BlankPage, memory keeps increasing.
Otherwise, if I don’t use x:Bind in BlankPage.xaml:
<Button Click="click_event" />
BlankPage will be released as normal and no memory leak happened.
So, is it a problem on x:Bind? Also, I tried with Bindings.StopTracking(); but doesn’t work.
Also asked at: https://docs.microsoft.com/en-us/answers/questions/898874/memory-leak-when-close-window-in-winui3.html Thanks
Steps to reproduce the bug
Click to open and close BlankPage window and resource of BlankPage’s view is not released.
Expected behavior
No response
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.1.1
Windows app type
- UWP
- Win32
Device form factor
No response
Windows version
No response
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
I just want to help to make this not get closed
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.