What is a Memory Leak and Garbage Collector in java?
A memory leak is the gradual loss of available memory when a program/application repeatedly fails to free memory that it has occupied for temporary use.
Consider that you have 10 glasses at your house. Whenever these glasses are used they will be cleaned up and kept ready in the stand for future use by the servant when he comes. If you have placed one of the glasses in a room where the servant is not permitted to enter or you have not consumed the juice completely and it is still left in the glass, the servant might think that the glass is still in use and hence he will not clean them.
If this scenario continues, one day you will find all the glasses are uncleaned, so you call the servant to clean all of them.
In java this servant is known as Garbage Collector.