Garbage Collection Java
Why Garbage Collection? In Programming languages like C, C++ the programmer is responsible for both creation and deletion of objects. So if the programmer forget to delete the object then the memory allocated to those objects will no longer be available. This way the used memory will goes on increasing and there will be no memory left to allocate for other processes. This causes memory leaks. So at a certain point we may face memory out of bound exception and program gets terminated. In general, we use some methods like free() or delete() to free up the memory in c and c++. But in Java, Garbage Collection is taken care automatically. What is Garbage Collection in Java? For every program to run there should be some memory allocated to it. After the task is completed the program should reclaim the memory it allocated. Garbage collection in Java is the process by which java performs automatic memory management. In simple terms, Garbage Collection is defined as the process of re...