I have a use case where I will need to generate millions (possibly hundreds of millions) of delegates with the same type signature. I'd like to know more about the memory usage characteristics. I have two questions:

1. Delegates have environment/context pointer. If the delegate does not capture/access any variables from the englobing function (if it behaves like a static nested function), will a context object be allocated anyways, or will this pointer be null? Does DMD optimize this case?

2. Delegates are a function pointer and an environment pointer. Are they passed/stored by value, as a struct would be, or heap allocated and passed by reference?

Reply via email to