Home > Back-end >  The 2020-12-01: in Java, what is safe and secure area?
The 2020-12-01: in Java, what is safe and secure area?

Time:12-02

The 2020-12-01: in Java, what is safe and secure area? # # f greatly architects a daily topic

CodePudding user response:

Security: there might be unsafe GC multithreaded environment recovery, the JVM in order to secure the recovery of memory, will be in Safe Point Point for recycling, the so-called Safe Point is Java threads can perform to a certain position at this time the JVM security, on the controlled object of recycling, so as not to cause the GC recycle is using object

Safety area: when a thread is unable to be safe, this time would require the safety area, safety area refers to a piece of code, reference relationship will not change, anywhere in the area of GC were safe, thread execution to a safe area code, first identify itself into the security area, so no need to worry about when the GC thread into the security area, thread to leave the safe zone will check whether the JVM is finished the GC Roots enumeration, if completed will continue, if not complete wait until received the signal can be safely left,

CodePudding user response:

HotSpot is not generated for each instruction OopMap, but only in the "specific location" recorded the information, these locations are called security point (Safepoint), both when the program execution is not in all places can pauses to GC, can only be suspended, when to safety points
In thread to the Safe Region of code, first identify itself has entered the Safe Region, and, when at that time the JVM to initiate the GC, don't tube identify themselves as Safe Region state of thread, the thread to leave the Safe Region, it will check to see if the system has been completed the root node enumeration (or is the whole process of GC), if done, the thread will continue, otherwise it will have to wait until receive Safe to leave the Safe Region of the signal,
  • Related