Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Garbage collection (computer science)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Form of automatic memory management}} {{About|garbage collection in memory management|garbage collection in a solid-state drive|Garbage collection (SSD)}} {{Use dmy dates|date=April 2019|cs1-dates=y}} {{Use list-defined references|date=July 2022}} [[File:Structure and Interpretation of Computer Programs p.764a.gif|thumb|400px|Stop-and-copy garbage collection in a [[Lisp (programming language)|Lisp architecture]]:<ref name="Abelson-Sussman_2016"/> Memory is divided into ''working'' and ''free'' memory; new objects are allocated in the former. When it is full (depicted), garbage collection is performed: All data structures still in use are located by pointer tracing and copied into consecutive locations in free memory.]] [[File:Structure and Interpretation of Computer Programs p.764b.gif|thumb|400px|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).]] In [[computer science]], '''garbage collection''' ('''GC''') is a form of automatic [[memory management]].<ref name="techtarget">{{Cite web |title=What is garbage collection (GC) in programming? |url=https://www.techtarget.com/searchstorage/definition/garbage-collection |access-date=2024-06-21 |website=Storage |language=en}}</ref> The ''garbage collector'' attempts to reclaim memory that was allocated by the program, but is no longer referenced; such memory is called ''[[garbage (computer science)|garbage]]''. Garbage collection was invented by American computer scientist [[John McCarthy (computer scientist)|John McCarthy]] around 1959 to simplify manual memory management in [[Lisp (programming language)|Lisp]].<ref name="McCarthy_1960"/> Garbage collection relieves the programmer from doing [[manual memory management]], where the programmer specifies what objects to de-allocate and return to the memory system and when to do so.<ref name="techtarget"/> Other, similar techniques include [[stack-based memory allocation|stack allocation]], [[region inference]], and memory ownership, and combinations thereof. Garbage collection may take a significant proportion of a program's total processing time, and affect [[computer performance|performance]] as a result. Resources other than memory, such as [[network socket]]s, database [[Handle (computing)|handle]]s, [[Window (computing)|window]]s, [[File (computing)|file]] descriptors, and device descriptors, are not typically handled by garbage collection, but rather by other [[Method (computer programming)|method]]s (e.g. [[Destructor (computer programming)|destructor]]s). Some such methods de-allocate memory also.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)