
Originally Posted by
movieman
Garbage collection is one of those concepts that seems like a good idea in theory, but turns out to be a bad idea in practice. It burns CPU collecting things that you already know are out of scope anyway (e.g. objects that would be created on the stack in C++), it bloats RAM usage because you have to let the garbage accumulate before its collected unless you want to waste all your CPU time looking for your five bytes of unused RAM, and it introduces lots of exciting issues like objects going away at random when you didn't expect it (because you forgot to keep a reference) or not going away when you did expect it (because you forgot to delete every reference). It also prevents the efficient use of destructors to clean up other resources.
[...]
I've worked on big C++ projects and big Java projects and we typically spent about the same amount of time fixing garbage collection issues in Java as fixing memory management in C++; and most of the C++ memory management issues turned out to be in third-party libraries because we almost never call new or delete directly ourselves.