I read (somewhere) that finalize() for a parent class is not guaranteed to be called when the subclass is garbage-collected, does this mean most developers override finalize() in the subclass and call super.finalize()?
I read (somewhere) that finalize() for a parent class is not guaranteed to be
Share
Finalize is not automatically called for the super class. So if you override finalize, the proper way to ensure the super class gets cleaned up would be
See this reference article http://www.ibm.com/developerworks/java/library/j-jtp06294/index.html
It should be worth noting that finalizers are not very predictable and you don’t have any control over if/when they run. Nothing critical should be done in finalize methods. In general it is better practice to just perform explicit cleanup of your class.