I'd been wondering if the local variables in an async method in .Net will be Garbage Collected when not in use anymore. This will be extremely important for long-running Tasks.
For example, take this method as an example:
async void IterateForAnIternity()
{
int c = 0;
SomeClass _class = new SomeClass();
while(true)
{
int newVar = c * c;
LogMessage log = new LogMessage($"new var is now {newVar}");
log.Print();
var _tmp = _class.ReturnSomeBigStruct();
await return Task.Yield();
}
}
(the syntax may be wrong, but you get the idea)
If there's any docs on this, I'd appreciate it if you linked. I couldn't find anything online.