-
Notifications
You must be signed in to change notification settings - Fork 667
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
Datagrid sorting memory leak #7641
Comments
@michael-hawker FYI - I believe this is on WCT. |
Looks similar/the same to this one that was also filed: CommunityToolkit/WindowsCommunityToolkit#4737 I asked if @RBrid had a few moments to assist as this is still all code that was contributed by the WinUI team. FYI @ryandemopoulos |
After further investigation this is not related to the datagrid itself. It's due to the creation of a new Observable Collection on each sort as shown in the sample code of the documentation: The right way is to use the same observable collection (clear and repopulate the same observable collection on each sort). |
Thanks for the info on your investigation @FrancoisKr. I would have thought the garbage collector would clean-up old collections, so it's still a bit odd. I suppose there should at least be an issue on the docs repo to improve the sample maybe? |
Yes it is a bit odd. From my observations, the garbage collector does seem to clean-up the old collections but not fast enough. And yes the documentation should definitely be improved. Thanks |
@gabbybilka how do you want to best track this? Should this issue remain here and updated to call out the sample/docs or open a separate issue in the https://github.com/MicrosoftDocs/WindowsCommunityToolkitDocs repo where this documentation lives? |
Describe the bug
When clicking multiple times on columns headers with sorting implemented, memory usage increases on each click (sort) and eventually the application will crash with the following exception:
Message = "Insufficient memory to continue the execution of the program."
Steps to reproduce the bug
Set up a datagrid with sorting as per:
https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid_guidance/group_sort_filter
Click multiple times on column headers
Memory usage increases on each click
Expected behavior
Datagrid is sorted without memory leak
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.1.4
Windows app type
Device form factor
Desktop
Windows version
Windows 10 (21H2): Build 19044
Additional context
No response
The text was updated successfully, but these errors were encountered: