Do you use D's GC?

Mike Parker aldacron at gmail.com
Sun Aug 1 11:15:30 UTC 2021


On Sunday, 1 August 2021 at 10:36:52 UTC, IGotD- wrote:

>
> There is one question I have, let's say you have a big game 
> that uses several gigabytes of RAM. The objects are just 
> allocated once with the GC but once you touch the GC like doing 
> a new (which can be done by a library function), will the GC 
> then start to scan all those gigabytes of data?

If it needs to. Not every allocation will trigger a collection. 
You can play around with something like appending items to an 
array in a loop and passing `--DRT-gcopt=profile:1` to the 
program when you run it. This will spit out a report telling you 
how many collections were run, along with some timing statistics. 
There's an example here:

https://dlang.org/blog/2017/06/16/life-in-the-fast-lane/

It's one of the tools available to make the best use of the GC.


More information about the Digitalmars-d mailing list