Skip to content

Instantly share code, notes, and snippets.

@BrennanConroy
Last active May 28, 2019 06:37
Show Gist options
  • Save BrennanConroy/da496cfc97b11d69657f83b68de2b5a0 to your computer and use it in GitHub Desktop.
Save BrennanConroy/da496cfc97b11d69657f83b68de2b5a0 to your computer and use it in GitHub Desktop.
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