GC behavior

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 6 09:55:46 PDT 2014


"Jonathan"  wrote in message news:hsdxglmqtcnhskwzrkph at forum.dlang.org...

> If I pool all unused objects such that no object needs to be GC'ed, does 
> it still perform scanning? What are other good ways to avoid its overhead? 
> As you might tell, I know rather little how D's garbage collection works. 
> I'm working on a game engine and trying to be as resource efficient as 
> possible.

A GC collection will run when you allocate with 'new' and there is not 
enough memory already reserved by the gc.  So if you don't use 'new' then it 
won't run a collection, otherwise it might.  You can disable all collections 
by importing 'core.memory' and calling 'GC.disable()'. 



More information about the Digitalmars-d mailing list