Definition
Whenever a variable is defined and assigned a value, actual memory space is allocated to store this value.
Throughout the program's runtime, some of these values are no longer used and linger around in memory.
Garbage collection is the process of analyzing code and knowing when a stored value will no longer be used even though the program is not done running.
Summary
Garbage collection ensures that a computer's memory is used effectively. This is usually a part of an interpreter [→] or compiler [→]
Here is another article you might like 😊 What Is A Global Variable?