Monday, 22 September 2014

What is Garbage Collection

Usually programmer taking very much care while creating the Objects and his neglecting destruction of Useless objects. Due to this neglectance at certain point of time  for the creation of new object sufficient memory may not be available and entire program will be collapse due to memory problems.

But in Java, "as a programmer is responsible only for  creation of objects and he is not responsible for destruction  of useless objects".

Java provided one assistant which is running in the background for destruction of useless Objects. Due to this assistant the chance of failure java program with memory problem i very rare. This assistant is nothing "Garbage Collection".

Hence the main objective of Garbage Collection is to "Destroy useless bojects".

When Garbage Collection is Required?
Programmer is not responsible to destroy useless objects, But It is always a good programming practice to make an object eligible for Garbage collection, if it is no longer required.

An object is said to be eligible for garbage collection , If it is doesn't contain any reference.


No comments:

Post a Comment