Garbage collection is a term used in object orientated programming.

A system to delete objects automatically to free memory.

When you make a program, you may create thousands of objects. All of these objects hold space in your computers memory.

Related course: Complete Python Bootcamp: Go from zero to hero in Python 3

Garbage Collection in Python

Python supports garbage collection, but in some programming languages you have to clean objects yourself.

You can delete objects manually if you want to.

Everything is an object in Python: we define a simple variable x and use that.
During runtime we delete the object and try to output it.

x = 3
del x

This will output:
Traceback (most recent call last):
File "", line 5, in <module>
NameError: name 'x' is not defined

In the first 2 lines of the program object x is known. After deletion of the
object x cannot be printed anymore.

Garbage collection is completely automated, you do not have to worry about it.

The del() destructor is called just before an object is destroyed.