Garbage collection is a memory management technique that automatically identifies and frees memory objects a program no longer references. It was devised by John McCarthy for Lisp in 1959 and is built into the runtimes of many programming languages, including Java, C#, Python, Go, and JavaScript. Because developers do not have to free memory by hand, it reduces errors such as memory leaks and dangling pointers.
More broadly, the term also describes the work a storage system does to discard data that is no longer needed. Git, for example, provides the git gc command, which removes unreachable objects and packs loose objects into packfiles.