Unsourced material may be challenged and removed. Please help improve this article by adding citations to reliable sources. This section needs additional citations for verification. Some GC systems allow such other resources to be associated with a region of memory that, when collected, causes the work of reclaiming these resources. Methods for managing such resources, particularly destructors, may suffice to manage memory as well, leaving no need for GC. Resources other than memory, such as network sockets, database handles, user interaction windows, file and device descriptors, are not typically handled by garbage collection. Garbage collection may take a significant proportion of total processing time in a program and, as a result, can have significant influence on performance. Other similar techniques include stack allocation, region inference, memory ownership, and combinations of multiple techniques.
Garbage collection relieves the programmer from performing manual memory management where the programmer specifies what objects to deallocate and return to the memory system and when to do so. 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).