Java provides the automatic garbage collection facility.JVM performs the garbage collection to free up the unnecessary memory which can\'t be reached through the object reference. We can\'t force the JVM to perform the garbage collection, but we can request the JVM by our program to to call the method System.gc(), but it is upto JVM to perform garbage collection or not.