27.12.11

HotSpot Runtime / DestroyJavaVM

openjdk.java.net/groups/hotspot/docs/RuntimeOverview.html#VM%20Lifecycle|outline

DestroyJavaVM

This method can be called from the launcher to tear down the VM, it can also be called by the VM itself when a very serious error occurs.
The tear down of the VM takes the following steps:
  1. Wait until we are the last non-daemon thread to execute, noting that the VM is still functional.
  2. Call java.lang.Shutdown.shutdown(), which will invoke Java level shutdown hooks, run finalizers if finalization-on-exit.
  1. Call before_exit(), prepare for VM exit run VM level shutdown hooks (they are registered through JVM_OnExit()), stop theProfilerStatSamplerWatcher and GC threads. Post the status events to JVMTI/PI, disable JVMPI, and stop the Signal thread.
  1. Call JavaThread::exit(), to release JNI handle blocks, remove stack guard pages, and remove this thread from Threads list. From this point on we cannot execute any more Java code.
  2. Stop VM thread, it will bring the remaining VM to a safepoint and stop the compiler threads. At a safepoint, care should that we should not use anything that could get blocked by a Safepoint.
  3. Disable tracing at JNI/JVM/JVMPI barriers.
  4. Set _vm_exited flag for threads that are still running native code.
  5. Delete this thread.
  6. Call exit_globals(), which deletes IO and PerfMemory resources.
  7. Return to caller.

No comments: