Home : Software Terms : Garbage Collection Definition

Garbage Collection

In computer science, garbage collection is a type of memory management. It automatically cleans up unused objects and pointers in memory, allowing the resources to be used again. Some programming languages have built-in garbage collection, while others require custom functions to manage unused memory.

A common method of garbage collection is called reference counting. This strategy simply counts how many references there are to each object stored in memory. If an object has zero references, it is considered unnecessary and can be deleted to free up the space in memory. Advanced reference counting detects objects that only reference each other, which indicates the objects are unused by the parent process.

Garbage collection may also be done at compile-time, when a program's source code is compiled into an executable program. In this method, the compiler determines which resources in memory will never be accessed after a certain time. It can then add instructions to automatically deallocate those resources from memory. While this is an effective way to eliminate unused objects, it must be done conservatively to avoid deleting references required by the program.

Garbage collection is an important part of software development since it keeps programs from using up too much RAM. Besides helping programs run more efficiently, it can also prevent serious bugs, such as memory leaks, that can cause a program to crash.

Updated: January 20, 2016

Cite this definition:


TechTerms - The Tech Terms Computer Dictionary

This page contains a technical definition of Garbage Collection. It explains in computing terminology what Garbage Collection means and is one of many software terms in the TechTerms dictionary.

All definitions on the TechTerms website are written to be technically accurate but also easy to understand. If you find this Garbage Collection definition to be helpful, you can reference it using the citation links above. If you think a term should be updated or added to the TechTerms dictionary, please email TechTerms!

Subscribe to the TechTerms Newsletter to get featured terms and quizzes right in your inbox. You can choose to receive either a daily or weekly email.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe at any time.
Questions? Please contact us.