What is Garbage collection?

Garbage collection is used to prevent memory leaks during execution of programs. There is a low-priority process name as garbage collector manages the allocation and deallocation a memory for applications. It also checks for the unreferenced variables and objects. If there is ny object which is no further used by application the Garbage collector frees up the memory from that object.