The basic thing in everyone’s life was to keep the environment clean to stay healthy, for this normally we use a word called “Garbage Collector“.The purpose of this garbage collector was to collect the dust and keeping the environment clean.The same concept has been implemented in the computer science to save the memory of the disk from unwanted classes and objects.It was considered to be the resource management where the memory was restricted from the unwanted objects that were used in the program.
Normally, if a program was created using a different type of classes and objects that were neither useful for the program or result,then the memory will be unwantedly occupied and the speed of the system and the result set will get slowed and even the expected result may not come due to the “Memory Parse Error“.This was a big challenge to the programmers until the year 1959,but JohnMccarthy introduced the automatic garbage collector that collects the memory of unwanted classes and objects.Garbage Collection was used by several languages such as Java,C,C++,Perl and utmost all the scripting languages use the purpose for their memory management.

The action from the Garbage collection occurs during the time of compilation and some times during the run-time.There are some basic principles for GC (Garbage Collection), their functionality should follow the objects that are declared in the program which are not useful for the program at present and future.Hence,it helps the developers to release their tension by removing the unwanted classes and objects in the program that were useless.Some of the disadvantages of the garbage collector was their worst locality that occupies more address space than really a program uses.
Sometimes,due to the garbage collection the system and result set can be slowed down.Let us take an example:
import java.util.Vector;
public class GarbageCollector{
public static void main(String[] args) {
int SIZE = 600;
StringBuffer p;
for (int x = 0; x < SIZE;x++) {
}
System.out.println(“You are Using Garbage Collection and It Has been Started now”);
long time = System.currentTimeMillis();
System.gc();
System.out.println(“It took ” + (System.currentTimeMillis()-time) + ” ms”);
}
}
Their output would be as the following:
D:\java>javac GarbageCollector.java
D:\java>java GarbageCollector
You are Using Garbage Collection and It Has been Started now.
It took 678 ms.

Similarly the garbage collector can be used in several languages.They have been widely used by every programmers and developers to sort out their burdens in case of memory management.
Thanks