WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

Memoryleak on DataGrid TableHeader

Open KenionX opened this issue 1 year ago • 2 comments

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

devenv_2USYr4idPF

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.

KenionX avatar Aug 25 '22 13:08 KenionX

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 🙌

msftbot[bot] avatar Aug 25 '22 13:08 msftbot[bot]

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

michael-hawker avatar Aug 25 '22 21:08 michael-hawker

This issue is reproduceable on UWP: App1.zip

Arlodotexe avatar Sep 29 '22 22:09 Arlodotexe

I'm still looking for what exactly causes this, but after investigating I've found that this line is causing extra allocations:

image

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.

Arlodotexe avatar Sep 29 '22 22:09 Arlodotexe