Since objects are dynamically allocated by using the new operator, you might be wondering how such objects are destroyed and their memory released for later reallocation. The technique that accomplishes this is called garbage collection. It works like this when no reference to an object exist , that object is assumed to be no longer needed, and the memory occupied by the object can be reclaimed.