Exception in the completion method

Possible duplicate:
terminate and exclude a method

The garbage collector calls the method finalize()when the object is about to be freed from memory. What happens when an exception occurs in a method finalize()?

Will the GC continue on and free the memory, or will the GC stop the process for this object?

+5
source share
2 answers

If the exception is expressed in the try-catch statement and correctly caught, then yes, "GC will continue next", as is the case in regular programs.

But if the processed exception is not processed, then, according to JSL ,

, .

, "GC ", , .

, 2 :

  • , finalize ( )

    , , ? , JVM.

  • ( ) GC , , GC. (cf Java Tuning 2nd, Edition Jack Shirazi).

+8

All Articles