Skip to content

Instantly share code, notes, and snippets.

@BrennanConroy
Last active May 28, 2019 06:37
Embed
What would you like to do?
Hidden allocations of .NET

Intro: always measure first and test after

Start simple:

  • class vs. struct

  • pre-alloc container sizes if possible

  • string.Substring(1, 10);

  • stackalloc byte[]/Span

  • for loops vs. foreach loops

  • closures

  • avoid unnecessary async statemachine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment