• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finally block and non-memory resources

 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read that the finally block is used to release non-memory resources.

On the other hand, nonmemory resources like file handles and socket handles must be explicitly released by the program, using methods with names like close(), destroy(), shutdown(), or release().



Why are these resources called non-memory?
Even if I open an RMI socket, I agree that the objects are constructed on a different heap area (diff. JVM), but still it comsumes some area in my JVM?
Also, why IO streams called as non-memory resources?

pls help..
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really mean try, catch, finally? Or the overridden Object.finalize() method?

For the SCJP you only need consider resources in the same JVM. An IO stream would be allocated an operating system resource (a filehandle) which you should return if not being used.
[ November 30, 2006: Message edited by: Barry Gaunt ]
 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup! i meant the finally, not the finalize method in the Object class..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic