Memory leak in DataGrid when grouping?

Dec 8, 2009 at 5:44 PM

Our application, which uses a DataGrid (latest version) with grouping, is showing a significant memory leaking when the user sorts columns. Basically, each time the user clicks on a column to sort, a bit of memory is chewed up, and never seems to be released. It's pretty easy to get the app using over 200 MB (starting around 60MB) with a few clicks.  When I turn off grouping, the memory usage stabilizes, staying around 80MB.

Anyone else seeing this? Any fixes?

Dec 8, 2009 at 11:13 PM
Edited Dec 8, 2009 at 11:29 PM

I spent the day tracing through the toolkit and WPF source, and I think I have at least a partial understanding of what's happening (though I won't claim to understand it in depth - there's helluva lot of code involved).

It looks like in Grouping mode, the row's row.Tracker.StopTracking method is never called, because ClearContainerForItemOverride is never called by the WPF ItemsControl implementation. The result is that you just end up with an ever growing chain of ContainerTracking instances.

No idea how to fix the problem, though. Anyone?

 

 

Dec 17, 2009 at 11:48 PM

Note that Microsoft has acknowledged that this is a bug, being fixed in .NET 4.0. No fix for .NET 3.5 at this time.

Jun 23, 2010 at 5:30 PM

was the fix for 4.0 ever committed to the codeplex source? Was it released in the Feb or March 2010 releases of the WPF Toolkit?

Jun 23, 2010 at 5:38 PM

The fix was actually in the .NET framework, not the toolkit itself. From what I understand, it isn't fixable in just the toolkit, so it won't ever be fixed on .NET 3.5. 

Jun 23, 2010 at 7:41 PM

This is unfortunate.

there are already "bugs" fixed in the toolkit that make the WPF Toolkit version of DataGrid better to use than the version released in 4.0.

I presume since it is open source, I am free to attempt to fix this bug myself?