Garbage collection was invented by American computer scientist John McCarthy around 1959 to simplify manual memory management in Lisp.
[2] Other, similar techniques include 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 performance as a result.
Still others, like D, are garbage-collected but allow the user to manually delete objects or even disable garbage collection entirely when speed is required.
Therefore, the penalty for the convenience of not annotating object lifetime manually in the source code is overhead, which can impair program performance.
[12] Interaction with memory hierarchy effects can make this overhead intolerable in circumstances that are hard to predict or to detect in routine testing.
The impact on performance was given by Apple as a reason for not adopting garbage collection in iOS, despite it being the most desired feature.
Otherwise, the object may be allocated directly on the stack and released when the function returns, bypassing the heap and associated memory management costs.
[22] Other dynamic languages, such as Ruby and Julia (but not Perl 5 or PHP before version 5.3,[23] which both use reference counting), JavaScript and ECMAScript also tend to use GC.
Object-oriented programming languages such as Smalltalk, ooRexx, RPL and Java usually provide integrated garbage collection.
BASIC and Logo have often used garbage collection for variable-length data types, such as strings and lists, so as not to burden programmers with memory management details.
[26] A replacement garbage collector for Applesoft BASIC by Randy Wigginton identifies a group of strings in every pass over the heap, reducing collection time dramatically.
[34][35] Garbage collection is rarely used on embedded or real-time systems because of the usual need for very tight control over the use of limited resources.
This form of garbage collection has been studied in the Mercury programming language,[39] and it saw greater usage with the introduction of LLVM's automatic reference counter (ARC) into Apple's ecosystem (iOS and OS X) in 2011.
[43] Generational garbage collection schemes are based on the empirical observation that most objects die young.