Garbage collection and closures.

ANtlord via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 17 06:03:28 PDT 2017


Hello! I can't understand one thing related to closures and 
calling of GC. I have the following demo snippet, where a closure 
is passed to `receive` function in a loop.

bool isDone = false;
while(!isDone)
	receive((bool val){ isDone = val });

Is GC called every iteration of this loop?

I know that I can move the code to a method of a struct and make 
the closure and variable "isDone" as fields of the struct. It 
avoids GC calling definitely. But I want to get how many times GC 
is called in case of a closure in a loop.

Thanks.


More information about the Digitalmars-d-learn mailing list