Garbage collection is automatic memory management: a collector finds memory a program can no longer reach and frees it.
John McCarthy invented garbage collection around 1959 to simplify memory management in Lisp. It prevents mistakes such as freeing the same memory twice, at the cost of extra work while the program runs and pauses that are harder to predict. Java, C# and Go use garbage collectors; C, C++ and Rust do not.
Source Wikipedia Shared under CC BY-SA 4.0