Disabling the Garbage Collector

Adam D. Ruppe destructionator at gmail.com
Mon Mar 3 17:11:04 PST 2014


On Monday, 3 March 2014 at 12:23:49 UTC, Jeroen Bollen wrote:
> If I were to compile without linking to the garbage collector, 
> what would and what wouldn't work in D?

You can get almost everything to work, though some built-in 
features will need to be replaced/supplemented by library things 
and some care will be needed to avoid memory leaks.

Specifically:

* the a ~ b operator is a bad idea without the GC. (and with the 
GC in performance critical code)

* delegate closures are a bad idea without the GC (though you can 
make them work)

* Your classes will be written pretty differently

* ~=, .dup and .length on built in arrays will need to be 
replaced by a library thing


I think the rest can be made to work off the top of my head. 
Though, I think the cases where you want to go without the GC 
entirely are pretty rare. Normally, I'd just be careful about 
where you trigger it instead.


More information about the Digitalmars-d-learn mailing list