Garbage Collector (GC) is a program or mechanism that automatically frees up memory space in a computer’s memory (RAM) that is no longer being used by the program. It is a type of memory management system that helps prevent memory leaks and memory fragmentation, which can cause a program to crash or become unstable.
When a program creates an object or allocates memory, the Garbage Collector keeps track of its usage and determines whether it is still in use by the program. If the GC finds that the object or memory is no longer being used, it marks it as garbage and reclaims the memory.
There are different types of Garbage Collectors, including reference counting, tracing, and generational. Each type has its own approach to detecting and collecting garbage, and the best choice depends on the application’s requirements.
GC is commonly used in programming languages such as Java, Python, and C#. While GC can provide significant benefits in terms of memory management and program stability, it can also impact performance and introduce latency. Therefore, it is essential to consider the trade-offs when choosing the right GC algorithm for an application.
In this article we will present a general idea of what is a garbage collector, tips for organization and we will also persent some of their basics algorithms thoughout the years.