dotnet / dotnet/wpf

Unnecessary delegate/closure allocations in UIElementAutomationPeer

Open
#10,676 0 comments 1 reaction 1 assignee Claimed by @h3xds1nz View on GitHub
Performance
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

_Note that I will submit a PR in the coming days for this issue, so its more of an FYI._

### Description

`GetChildrenCore` and `GetRootAutomationPeer` both allocate a new delegate and closure each time they execute with the call to `iterate` function that the callback is passed into. Given that both capture a single local parameter, we can easily just modify the function signature and pass the parameter by `ref`, saving easily 220 MB in this case.

### Showcase

![Image](https://github.com/user-attachments/assets/b1e7d42c-d972-4343-a77b-4239d16c748c)

### Repro

Note: This repro is specifically crafted to highlight an issue like this.

https://github.com/h3xds1nz/UIAPerformancePitfalls

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.