In object-oriented programming languages (like C++ and Java), there could be unused objects that are still a part of the program. These will create undesirable results like an out of memory error, for instance, during run-time, if left unattended. The memory occupied by such objects is known as ‘garbage’ and the mechanism to eliminate this from the program is called ‘garbage collection’.
Unlike C++, Java provides the programmer with an assistant to delete useless objects, which is called the garbage collector. In Java, there is no Out Of Memory Error thanks to the garbage collector, which destroys unused objects. Java is also called a robust programming language because of such mechanisms. Because of this background mechanism, the stress on the programmer is significantly less.
Written by one of our mentors, January 2015 edition of Open Source For You (OSFY) is having an article titled ‘Performing Garbage Collection in Java’ got published. Here is the URL to download the complete PDF version of the article: