ALERT

[WEBINAR] Building a Business-Driven Data Architecture

Garbage Collection (GC)

Definition - What does Garbage Collection (GC) mean?

Garbage collection (GC) is a dynamic approach to automatic memory management and heap allocation that processes and identifies dead memory blocks and reallocates storage for reuse. The primary purpose of garbage collection is to reduce memory leaks.

GC implementation requires three primary approaches, as follows:

  • Mark-and-sweep - In process when memory runs out, the GC locates all accessible memory and then reclaims available memory.
  • Reference counting - Allocated objects contain a reference count of the referencing number. When the memory count is zero, the object is garbage and is then destroyed. The freed memory returns to the memory heap.
  • Copy collection - There are two memory partitions. If the first partition is full, the GC locates all accessible data structures and copies them to the second partition, compacting memory after GC process and allowing continuous free memory.

Some programming languages and platforms with built-in GC (e.g., Java, Lisp, C# and .Net) self-manage memory leaks, allowing for more efficient programming.

Techopedia explains Garbage Collection (GC)

Garbage collection's dynamic approach to automatic heap allocation addresses common and costly errors that often result in real world program defects when undetected.

Because they are difficult to identify and repair, allocation errors are costly. Thus, garbage collection is considered by many to be an essential language feature that makes the programmer’s job easier with lower manual heap allocation management. However, GC is not perfect, and the following drawbacks should be considered:

  • When freeing memory, GC consumes computing resources.
  • The GC process is unpredictable, resulting in scattered session delays.
  • When unused object references are not manually disposed, GC causes logical memory leaks.
  • GC does not always know when to process within virtual memory environments of modern desktop computers.
  • The GC process interacts poorly with cache and virtual memory systems, resulting in performance-tuning difficulties.
This definition was written in the context of General Programming

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
Free Whitepaper: The Path to Hybrid Cloud
Free Whitepaper: The Path to Hybrid Cloud:
The Path to Hybrid Cloud: Intelligent Bursting To Amazon Web Services & Microsoft Azure
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.