Re: Closures and memory allocation

2019-06-22 Thread kinke via Digitalmars-d-learn
On Saturday, 22 June 2019 at 16:52:07 UTC, Anonymouse wrote: When entering the following function, does it allocate: 1. 0 times, because while there are closures defined, none is ever called? 2. 2 times, because there are closures over two variables? 3. 20 times, because there are 20 unique

Re: Closures and memory allocation

2019-06-22 Thread Cym13 via Digitalmars-d-learn
On Saturday, 22 June 2019 at 19:26:13 UTC, Cym13 wrote: On Saturday, 22 June 2019 at 16:52:07 UTC, Anonymouse wrote: [...] Clearly this is a good time for you to learn about the tools D offers to profile allocations. There is the --profile=gc DMD argument that you can use but here there's

Re: Closures and memory allocation

2019-06-22 Thread Cym13 via Digitalmars-d-learn
On Saturday, 22 June 2019 at 16:52:07 UTC, Anonymouse wrote: I'm looking into why my thing does so many memory allocations. Profiling with kcachegrind shows _d_allocmemory being called upon entering a certain function, lots and lots of times. It's a function that receives concurrency

Closures and memory allocation

2019-06-22 Thread Anonymouse via Digitalmars-d-learn
I'm looking into why my thing does so many memory allocations. Profiling with kcachegrind shows _d_allocmemory being called upon entering a certain function, lots and lots of times. It's a function that receives concurrency messages, so it contains nested functions that close over local