Showing posts with label Garbage Collector. Show all posts
Showing posts with label Garbage Collector. Show all posts

Garbage Collector Program in JAVA

  • 0
Java language dynamically allocates the memory to the objects of the classes being used in the program. Unlike C++ where a destructor is needed to free the memory, JAVA employs Garbage Collector Mechanism to reclaim the allocated memory. When no referance to the object exists in the memory, it becomes eligible to be collected by Garbage Collector. The finalize method provided by java sees to it that this method is executed just before the memory allocated to the object is being reclaimed. There is no gurantee that a finalize method would be executed. My aim was to observe the functioning of the garbage collector. So, I created a program. And here it is.