Garbage collection is a form of automatic memory management used in computer programs to reclaim memory occupied by objects that are no longer needed. John McCarthy invented garbage collection for Lisp in 1959. Languages either use garbage collection or require manual memory management through techniques like allocating and freeing memory. Common garbage collection algorithms include reference counting, mark and sweep, and generational collection. The Java Virtual Machine uses different garbage collectors like serial, parallel, concurrent mark and sweep, and Garbage First collectors to reclaim memory in the Java heap.