Changes

Jump to navigation Jump to search
expand
Line 1: Line 1:  
In [[computer science]], '''garbage collection''' is the process in which memory that was dynamically allocated during the execution of a program is reclaimed after its execution.<ref>{{cite web|url=http://dictionary.reference.com/browse/garbage+collection?jss=0 | title=Garbage collection }}</ref>
 
In [[computer science]], '''garbage collection''' is the process in which memory that was dynamically allocated during the execution of a program is reclaimed after its execution.<ref>{{cite web|url=http://dictionary.reference.com/browse/garbage+collection?jss=0 | title=Garbage collection }}</ref>
 +
 +
==Garbage Collection Algorithms==
 +
 +
;Mark and Sweep:The Mark and Sweep algorithm involves two phases. First, it marks all reachable objects in memory. Then, in the sweep phase, it reclaims memory occupied by unmarked (unreachable) objects. It's a simple yet effective technique.
 +
;Generational [[Garbage]] Collection:Generational garbage collection is based on the observation that most objects become unreachable shortly after they are created. It divides memory into multiple generations and prioritizes garbage collection in the younger generations, promoting objects that survive multiple collections to older generations.
 +
;Reference Counting:Reference counting maintains a reference count for each object. When an object's reference count drops to zero, it is considered unreachable and is deleted.
 +
;Copying and Compacting:This [[algorithm]] divides memory into two semi-spaces. Objects are initially allocated in one semi-space. When garbage collection occurs, reachable objects are copied to the other semi-space, and the memory is compacted. This approach is particularly effective for memory fragmentation.
 +
 +
==Languages that use GC==
 +
*[[Java]]
 +
*[[C Sharp|C#]]
 +
*[[Python (programming language)|Python]]
    
== Pointer Management ==
 
== Pointer Management ==
SkipCaptcha, Automoderated users, edit
730

edits

Navigation menu