wpf icon indicating copy to clipboard operation
wpf copied to clipboard

System.Windows.UncommonField<bool>.SetValue generating garbage

Open yingDev opened this issue 4 years ago • 1 comments

When scrolling a VirtualizingStackPanel, this line of code does lots of boxing of bool values. thus leading to frequent GC.

https://github.com/dotnet/wpf/blob/d49f8ddb889b5717437d03caa04d7c56819c16aa/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/UncommonField.cs#L54

Maybe it should by optimized for boolean type ?

Here's the call stack:

UncommonField<bool>.SetValue() 
TreeViewItem.System.Windows.Controls.Primitives.IHierarchicalVirtualizationAndScrollInfo.set_MustDisableVirtualization() 
VirtualizingStackPanel.SetViewportForChild() 
VirtualizingStackPanel.MeasureChild() 
VirtualizingStackPanel.MeasureOverrideImpl() 
VirtualizingStackPanel.MeasureOverride() 
FrameworkElement.MeasureCore()
UIElement.Measure()
ContextLayoutManager.UpdateLayout() 
ContextLayoutManager.UpdateLayoutCallback()
...

yingDev avatar Jan 31 '21 20:01 yingDev

Thanks, @yingDev. I've added this to our performance backlog.

ryalanms avatar Feb 01 '21 19:02 ryalanms