Why does D rely on a GC?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 18 16:21:02 PDT 2014


Various reasons:
1. Memory safety. A whole class of bugs are eliminated by the use
of a GC.
2. It is faster on multithreaded systems than RC (as the
reference count must be synchronized properly).
3. Having all the heap under GC control is important so that the
GC won't delete live objects.

If you are willing to get rid of 1., D's allow you to free object
from the GC explicitly via GC.free, which will bring you back to
a manual memory management safety and performance level, but will
still provide you with a protection net against memory leaks.


More information about the Digitalmars-d mailing list