Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

async related heap allocations are not detected #73

Open
cristianiorga opened this issue Jun 29, 2019 · 1 comment
Open

async related heap allocations are not detected #73

cristianiorga opened this issue Jun 29, 2019 · 1 comment

Comments

@cristianiorga
Copy link

cristianiorga commented Jun 29, 2019

Just adding the async keyword to a function adds two heap allocations to that function. One is the state machine and one is the task method builder. Example: https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBY4AcoQGYEsA2MAJgDREgDUAPgAIBMAjALABQNAzAAT2cDCnAb1acR3LjQAc3FJwCyACgCUg4aIC+rNUA=

Not mentioning the Task/Task< T > allocations.

None of these are highlighted.

@cezarypiatek
Copy link
Contributor

cezarypiatek commented Jan 3, 2020

The state machine is a class only when the "Debug and Continue" option is enabled during the compilation, otherwise it's a struct and it's allocated on the stack. Please take a look on this thread to get more detailed explanation https://stackoverflow.com/questions/33871181/why-are-async-state-machines-classes-and-not-structs-in-roslyn

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants