Friday, July 3, 2015

Garbage collection in Java


Garbage Collection is one the important feature of programming language like JAVA which is related with the memory management. At the end of program execution, objects which go out of scope or which are no longer referenced in the programs Java Virtual Machine (JVM) reclaims the memory associated with them. Unlike C++, there is no need of freeing the memory by using free() method explicitly; instead JVM automatically frees the memory allocated by objects.

Fig: Garbage Collection

finalize() method is invoked whenever object is collected for garbage.So, One can place the code for releasing resourcing or closing of files inside this method by overriding this.

For more Details Refer following link:




No comments:

Post a Comment