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

Datagrid sorting memory leak #7641

Closed
1 of 2 tasks
FrancoisKr opened this issue Aug 24, 2022 · 7 comments
Closed
1 of 2 tasks

Datagrid sorting memory leak #7641

FrancoisKr opened this issue Aug 24, 2022 · 7 comments
Labels
area-External Not owned by the WinUI team, not actionable in this repository. bug Something isn't working wct

Comments

@FrancoisKr
Copy link

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

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

@FrancoisKr FrancoisKr added the bug Something isn't working label Aug 24, 2022
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Aug 24, 2022
@gabbybilka gabbybilka added wct area-External Not owned by the WinUI team, not actionable in this repository. and removed needs-triage Issue needs to be triaged by the area owners labels Aug 25, 2022
@gabbybilka
Copy link
Member

@michael-hawker FYI - I believe this is on WCT.

@michael-hawker
Copy link
Collaborator

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

@FrancoisKr
Copy link
Author

I don't have the problem with the mouse over, only when sorting the columns when sorting CanUserSortColumns="True".

This can be very easily reproduced and observed with the WCT sample app
Datagrid memory leak
.

@FrancoisKr
Copy link
Author

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:
https://learn.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid_guidance/group_sort_filter

The right way is to use the same observable collection (clear and repopulate the same observable collection on each sort).

@michael-hawker
Copy link
Collaborator

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?

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 4, 2022
@FrancoisKr
Copy link
Author

@michael-hawker

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

@michael-hawker
Copy link
Collaborator

@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?

@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-External Not owned by the WinUI team, not actionable in this repository. bug Something isn't working wct
Projects
None yet
Development

No branches or pull requests

4 participants