dotnet / dotnet/wpf

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

Open
#4,114 1 comment 3 reactions 1 assignee Claimed by @h3xds1nz View on GitHub
:construction: work in progress Performance
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

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:
```C#
UncommonField.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()
...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.