Main function of Garbage collector is to checks for objects/unused that are no longer being used by application. If it treated an object eligible for destruction. It calls the destruction and reclaims the memory used to store the object.

GC keeps tracks of all the objects and ensures that each object gets destroyed once.

GC ensures that objects, which are being referenced, are not destroyed.