3 ms·
GCs can be integrated with allocators to give you memory management. GCs can (not all do) 'move' live objects to compact memory giving better locality and thus
by eternalban 4y ago
GCs can be integrated with allocators to give you memory management. GCs can (not all do) 'move' live objects to compact memory giving better locality and thus performance. GC is applied by runtime and is systemic. If runtime is bug free so are the memory management bits of your code. Less code also reduces probability of bugs and lack of explicit memory management naturally reduces lines of code.
I think the reasonable questions are along the lines of 'when is it not a good idea to use a GC?'. Things like performance, restrictions its places on languages, explicit memory management, and also restrictions on what you can do in your code. The Boehm GC here, for example, has a limited sense of what are 'references' -- it only knows pointers -- so any kind of object composition scheme that is not based on pointers (or mushes pointers like XOR linked list) is seen as 'data' by the GC and could cause bugs.