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

Frame Navigation leaks memory. #4713

Closed
Noemata opened this issue Apr 1, 2021 · 11 comments
Closed

Frame Navigation leaks memory. #4713

Noemata opened this issue Apr 1, 2021 · 11 comments
Labels

Comments

@Noemata
Copy link

Noemata commented Apr 1, 2021

Steps to reproduce the bug

App1.zip

Steps to reproduce the behavior:

  1. Build attached app.
  2. Run app.
  3. Change pages using Go xxx Page buttons
  4. Watch memory growth using Task Manager

Expected behavior
Memory should be reclaimed.

Screenshots
n/a

Version Info

NuGet package version:
[Microsoft.UI.Xaml.2.6.0-prerelease.210315002]

Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
Device form factor Saw the problem?
Desktop Yes

Additional context

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Apr 1, 2021
@StephenLPeters StephenLPeters added area-TabView team-Controls Issue for the Controls team labels Apr 1, 2021
@StephenLPeters
Copy link
Contributor

@Noemata do you know if this is a regression with 2.6 or if it was present in 2.5 as well? If you call GC.Collect mannually does it fix the leak?

@StephenLPeters StephenLPeters added needs-author-feedback Asked author to supply more information. and removed needs-triage Issue needs to be triaged by the area owners labels Apr 1, 2021
@ghost ghost added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Apr 1, 2021
@asierpn
Copy link

asierpn commented Apr 2, 2021

@Noemata in my tests by removing the TabView and setting NavigationCacheMode = Disabled the memory seems to stay below 225 MB, but if you set NavigationCacheMode = Enabled the memory keeps growing, in this case it is the DataGrid that is causing the memory leaks with NavigationCacheMode = Enabled.

This scenario must be tested using all WinUI controls.

@StephenLPeters StephenLPeters removed the needs-triage Issue needs to be triaged by the area owners label Apr 2, 2021
@asierpn
Copy link

asierpn commented Apr 3, 2021

@Noemata at this moment you have the same questions that we have about UWP performance, there is memory leaks using NavigationCacheMode="Enabled" and there is also a delay when switching pages which we don't understand if all the visual tree of the page is cached. This delay increases when the visual tree of the page is big and also when the process is consuming so much memory caused by memory leaks, in low powered machines these delays are very noticeable, and if you stress the app during them you can crash it, this scenario can be easily reproduced with the XAML Controls Gallery official app.

I'll leave it to you to hound Microsoft on that one. I'm pretty sure they're sick of me already. @asierpn, suggest you file a separate issue for DataGrid with the sample below.

I hope they are not fed up with you, this feedback is necessary to improve the platform even if it is not pleasant to hear.

We don't use the DataGrid of the Windows Community Toolkit in our production app, I used it in this repro project to show you better our real scenario, we use a 3rd party DataGrid which has the same issue and we have reported it to our UWP controls provider.

@asierpn
Copy link

asierpn commented Apr 3, 2021

@Noemata It seems that Microsoft was aware of these issues for a long time and finally they have started to address them, at least the memory leaks: https://github.com/microsoft/CsWinRT/releases/tag/1.2.0.210402.1

And the issue with the delays navigating to cached pages must be directly related to #1633 and #3335, this other issue must be priorized.

@asierpn
Copy link

asierpn commented Apr 5, 2021

@Noemata your last results are very interesting, it is really hard to work with this kind of issues when VS is interfering in the tests, but still must be there some issues with frame navigation and memory leaks, open the official XAML Controls Gallery and navigate to each page, you will see how memory usage grows and render performance decreases, if the application is stressed it finally crashes.

I've to do more tests on my production app where we have navigation memory leaks to determine which controls or code is causing it.

@asierpn
Copy link

asierpn commented Apr 5, 2021

@Noemata I'm agree with you, I will restart all my tests to try to find what is causing the memory leaks in our app, your last sample is a good point to start, running it always outside VS.

@Noemata
Copy link
Author

Noemata commented Apr 6, 2021

The following testing tool is mostly self explanatory if you have a close look at the code: https://github.com/Noemata/RosettaNavigation

The tool may be used to test both performance and Navigation Frame memory issues for both WinUI and UWP.

@lukedukeus
Copy link

Somehow, this is still an issue, on windows 11 22000, winui 1.1 preview 3

@CalebPowell57
Copy link

@Noemata I'm running into this issue and wonder if you've found any workaround or solution? I've tried different target versions, different uwp versions. I've even tried not using frame navigation, but instead, setting the content of a page to another page. In each scenario, it seems on general render, memory is leaked.

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

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.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants