WindowsCommunityToolkit
WindowsCommunityToolkit copied to clipboard
Memoryleak on DataGrid TableHeader
Describe the bug
Moving the mouse over the table headers on a DataGrid will cause an event handler leak, resulting in a Memoryleak on the control
Regression
No response
Reproducible in sample app?
- [ ] This bug can be reproduced in the sample app.
Steps to reproduce
https://github.com/KenionX/Winui3MemoryLeak/tree/master
Move the mouse over the table headers
Expected behavior
No memory leak
Screenshots
Windows Build Number
- [ ] Windows 10 1809 (Build 17763)
- [ ] Windows 10 1903 (Build 18362)
- [ ] Windows 10 1909 (Build 18363)
- [ ] Windows 10 2004 (Build 19041)
- [X] Windows 10 20H2 (Build 19042)
- [ ] Windows 10 21H1 (Build 19043)
- [ ] Windows 11 21H2 (Build 22000)
- [ ] Other (specify)
Other Windows Build number
No response
App minimum and target SDK version
- [ ] Windows 10, version 1809 (Build 17763)
- [ ] Windows 10, version 1903 (Build 18362)
- [ ] Windows 10, version 1909 (Build 18363)
- [X] Windows 10, version 2004 (Build 19041)
- [ ] Other (specify)
Other SDK version
No response
Visual Studio Version
2022
Visual Studio Build Number
17.2.6
Device form factor
Desktop
Nuget packages
CommunityToolkit.WinUI.UI.Controls.DataGrid 7.1.2 Microsoft.WindowsAppSDK 1.1.4 Microsoft.Windows.SDK.BuildTools 10.0.22621.1 MvvmGen 1.1.5
Additional context
No response
Help us help you
No.
Hello KenionX, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
@RBrid I know you're busy, but I don't see where we'd be registering an event here in the Pointer Moved event or anything. If you had a couple of minutes to maybe point us in the right direction here, that'd be much appreciated. Thanks!
This issue is reproduceable on UWP: App1.zip
I'm still looking for what exactly causes this, but after investigating I've found that this line is causing extra allocations:
Commenting out the line, the memory increase goes away. Leaving the line there but removing all code in the handler, the memory increase comes back.
Attaching the event is causing this (not the event invocation or event handler), but for some reason it's only that one event. Still investigating.