Is it advisable to depend on finalize for all cleanups

Showing Answers 1 - 14 of 14 Answers

preeti

  • Jun 29th, 2005
 

The purpose of finalization is to give an opportunity to an unreachable object to perform any clean up before the object is garbage collected , and it is advisable 

  Was this answer useful?  Yes

shuaib

  • Aug 31st, 2005
 

I dont think we should rely on finalize to clean up the resources, i like the pattern followed by .NET framework classes, they implement a disposable interface, which contains a single method dispose, which can be called from other objects, so as soon as you are finished using the object, you can fire its close method, which should release all the expensive resources.

  Was this answer useful?  Yes

xortha

  • Mar 28th, 2007
 

definitely not. There're not guarantee that finalize() method will have been called because of possibility of program crashed etc (take a look into TiJ).

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions