Garbage collection is the process of freeing up unused memory. All classes and methods use the JVMs memory but in most cases they do not get cleared after they get used. The JVM does periodic checks to look for such unused memory objects and deletes them to provide for more space for the active components. The Garbage collection process is automatic and the programmer cannot control as to how and when it works.