This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection

 
Sonal Ray
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Can anybody tell me what will happen if uncaught exception occurs in finalilze() method?

I got the following from API
"...If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates. ..... Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored".

Does it mean that the object will NOT be eligible for garbage collection now,may be later some othertime it will be Garbage collected without calling the finalize() again (as finalize() can be called only ONCE for that object)?
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does it mean that the object will NOT be eligible for garbage collection now,may be later some othertime it will be Garbage collected without calling the finalize() again (as finalize() can be called only ONCE for that object)?

Yeah absolutely, it means that the garbage collection for that object terminates but still the object remains eligible and will be garbage collected sometime later, without calling finalize() all over again.
 
deshdeep divakar
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every Exception that is uncaught are handeled by Default Exception
Handler,regardless it is thrown in try block or finilally.As per my
knowledge of JLS
 
deshdeep divakar
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry the reply is
Every Exception that is uncaught are handeled by Default Exception
Handler,regardless it is thrown in try block or finilize.As per my
knowledge of JLS
 
deshdeep divakar
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry the reply is
Every Exception that is uncaught are handeled by Default Exception
Handler,regardless it is thrown in try block or finalize.As per my
knowledge of JLS
 
Nikhilesh Fonseca
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the Finalisze method terminate"NOramlly" or is it Halted...if it throws an uncaught exception..
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does the Finalisze method terminate"NOramlly" or is it Halted...if it throws an uncaught exception..

The finalize method gets halted. But the object is still eligible for GC and can be collected at a later stage
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And when later , it will be collected at this time finalize() method will get called or not ...

I think not , otherwise again exception , then interrupt , and again object will not collected ...

Right ?

Thanks .
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it will not get called, it will just collect the object because finalize() can be called only once for any object
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Animesh .
When you are giving exam .
I think you are well prepared at this time also .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic