-
Notifications
You must be signed in to change notification settings - Fork 678
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
TabView: Memory usage does not go down after opening/closing tabs #3597
Comments
@duke7553 can you see if this is resolved in the latest pre-release ? Do you happen to know if this regressed or something that is in older releases as well ? |
@ranjeshj Thanks for getting back to my issue. This has been an issue with use of TabView in our project for a long time. Probably since we switched to the WinUI TabView. Since this could very well be an issue with my app specifically, I am working on a sample project to demonstrate if the behavior is reproducible or not. I expect to add it to this issue report soon. |
Thanks @duke7553 for the clarification. A repro app would be great. |
@ranjeshj This is a WinUI v2.6 sample app which reproduces the bug in a minimal way. Download source code: When running this sample, you should expect to see memory usage creep up quite a bit. Closing any tab will clear the collection and now you should see an absent/negligible decline in memory usage of the app. |
@ranjeshj @StephenLPeters I've updated the repro project for this bug to WinUI v2.6. The issue is definitely still present and it makes using the TabView for any kind of robust XAML content a nonstarter. Please give it a look when you get a chance. 😔🙏🏻 |
@ranjeshj @StephenLPeters I did some more detective work on this: It looks like this bug still exists even when completely replacing TabView with a regular ListView in my repro app. Memory usage stays elevated despite clearing the ListView ItemSource. This includes setting it to null, removing each item one-by-one, and doing .Clear() on it. Should this behavior be expected of Page and XAML controls in general with C#? How can I free an item's memory usage after it's closed? Am I missing something, or is this just an awful bug reported by many, other users over the years. |
@duke7553 have you ensured that GC has run by calling GC.Collect() during your testing? |
@StephenLPeters Yes. The repro app does this after it clears the tabs |
Most of the memory growth is from unmanaged memory btw |
@StephenLPeters Is the team aware that this is an issue with TabView and ListView or is there something I'm doing incorrectly regarding coding practices with these controls? |
It is on our radar, thank you for raising the issues. |
@StephenLPeters Wow! Thanks for circling back and the transparency here. By any chance, would this fix already be present in WinUI Desktop? Or maybe UWP XAML is the only stack affected. This made my day! |
@RBrid do you know if the data template leak fix has made it into Winui3? |
@StephenLPeters, no I have not ported it to WinUI 3. No ETA for that unfortunately. |
@StephenLPeters @RBrid Has the OS fix shipped in Windows or the decoupled UI stack yet? |
We have made the fix but it has not shipped yet. We are working on porting it to WinUI3. |
@ojhad @RBrid @StephenLPeters Has this fix shipped yet? |
@ojhad @RBrid @StephenLPeters Should this be reopened? |
What a joke. Hopefully this repository situation improves in the coming years, or else it's abundantly clear that WinUI isn't sustainable nor is it a priority to Microsoft. |
This issue appears to be affecting File Explorer and Notepad as well. |
@ojhad Has that fix been ported into WinUI3? |
You would think that it would have been ported by now... This memory leak has been present for an embarrassingly long time. It's not like this is insignificant. Why are they dragging their feet on this? |
lol. Maybe they have been busy for a long time. |
I checked with the team, and the fix has been in WinUI3 since WinAppSDK 1.3 (ported via internal bug). It sounds like there are additional leaks beyond that fix. Please open a new issue with a repro for us to investigate those leaks. Thanks! |
It appears that there are invisible items in the WinUI TabView visual tree which stick around even after they are removed. This behavior isn't desirable because users could have many TabViewItems with memory-intensive pages as their content.
Steps to reproduce the bug
Steps to reproduce the behavior:
Expected behavior
TabView must support scenarios with robust XAML content inside the TabViewItems by freeing the memory when tabs are closed via removal from ObservableCollection.
Screenshots
Version Info
NuGet package version:
Microsoft.UI.Xaml 2.6.1
Additional context
Old comment: #1332 (comment)
The text was updated successfully, but these errors were encountered: