Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: Garbage Collection...
|
Posted: Apr 23, 2004 8:45 AM
|
|
You can't really depend on the finalize method getting called, so it isn't a safe place to release resources or do other necessary cleanup. As I understnd it, there there is no guarantee that the finalize method will ever be called, which make it next to useless. If you need to do some resource deallocation or other cleanup, then you should have some explicit close() or cleanup() method.
You can find some in-depth discussion of this topic in Bill Venners' articles on this site, in his book Inside the Java Virtual Machine and in Josh Bloch's book Effective Java.
|
|