Garbage collection was invented by American computer scientist John McCarthy around 1959 to simplify manual memory management in Lisp.
The garbage collector attempts to reclaim memory which was allocated by the program, but is no longer referenced-also called garbage. In computer science, garbage collection ( GC) is a form of automatic memory management.
After that, the working memory contents is discarded in favor of the compressed copy, and the role of working and free memory are exchanged (depicted).