Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary string[] allocations #72642

Merged
merged 1 commit into from
Mar 22, 2024
Merged

Remove unnecessary string[] allocations #72642

merged 1 commit into from
Mar 22, 2024

Conversation

jaredpar
Copy link
Member

The result of the GetAllItems call was a fresh string[] that was being copied via collection initializer into a List<T>. That produces unnecessary allocations. This is particularly problematic because these allocations tend to end up in the LOH.

Changed the API to be more explicit and consumer to not do the unnecessary allocations. This saved 73MB in LOH allocations.

The result of the `GetAllItems` call was a fresh `string[]` that was
being copied via collection initializer into a `List<T>`. That produces
unnecessary allocations. This is particularly problematic because these
allocations tend to end up in the LOH.

Changed the API to be more explicit and consumer to not do the
unnecessary allocations. This saved 73MB in LOH allocations.
@jaredpar jaredpar requested a review from a team as a code owner March 21, 2024 15:42
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 21, 2024
@jaredpar
Copy link
Member Author

@dotnet/roslyn-compiler PTAL

@jaredpar jaredpar merged commit c72ad86 into dotnet:main Mar 22, 2024
21 of 24 checks passed
@jaredpar jaredpar deleted the loh branch March 22, 2024 18:19
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Mar 22, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.10 P3 Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants