A garbage collector is a separate module usually incorporated in the runtime environments of interpretable languages. For example, C# and Java both have garbage collectors, which makes the life of programmers a lot easier. The garbage collector tracks all the object allocations in the code and deallocates once they are not in use anymore. It's called a garbage collector because it deletes the memory resource after it's been used: it collects the garbage left by programmers.
It's said that C++ programmers don't leave garbage after them, that's why the language doesn't have support for a garbage collector. Though programmers tend to defend the language stating that it doesn't have a garbage collector because it's a fast language, the truth is that it can survive without one.
Languages like C# compile the program into intermediate...