当前位置:网站首页>Learn JVM garbage collection 05 - root node enumeration, security points, and security zones (hotspot)
Learn JVM garbage collection 05 - root node enumeration, security points, and security zones (hotspot)
2022-07-05 12:15:00 【The king of early rising】
Catalog
What is root node enumeration ?
Root node enumeration
What is root node enumeration ?
Judge the life and death of the object according to the method of reachability analysis , We need to find every starting point . This search process is called root node enumeration .
How it works
up to now , All garbage collector root node enumeration operations must pause the user thread . In other words, it will face similar problems to memory defragmentation “Stop The World” .
Virtual machines have a way to directly get where object references exist . stay HotSpot in , Through a group called OopMap The implementation of the data structure of . Information about references will be recorded here .
safer
OopMap Will make information records at specific locations , These locations are called safety points .
The emergence of safety points , It also gives the thread a proper time to stop , When the program is executed , To execute above the safe point, stop .
selection
If there are many safety points , that OopMap It will be great. , The memory overhead becomes larger .
Few safety points , The waiting time of the garbage collector will be very long .
The selection of safety points requires a standard : With method calls 、 Loop jump 、 Abnormal jump, etc. , Instruction sequence reuse The instructions of the function will produce a safety point .
Why? ?
The selection of safe point location is basically based on “ Whether the program has the characteristics of long execution ” As the standard Make the selected , Because the execution time of every instruction is very short , The program is unlikely to be executed for a long time due to the length of instruction stream “ Long execution ” The most obvious feature of instruction sequence is the reuse of instruction sequence , For example, method calls 、 Loop jump 、 Abnormal jump All belong to instruction sequence reuse , So only instructions with these functions can produce safe points .
Thread the interrupt
Here the so-called thread interrupt , It means that the implementation makes the thread run to the nearest safe point and then stop . There are two ways to achieve
Active interrupt 、 Preemptive interrupt
Active
In a safe place , Set up a Polling flag bit , When interruptions are needed , Set to true .
When a thread executes an instruction to a safe point , The polling flag bit will be checked . If it's true , Then the thread suspends itself , Implementation interrupt .
besides , It also needs to be set on the instructions that need to allocate memory Polling flag bit . Ensure that garbage collection is performed before allocating memory .
Preemptive ( Almost no use )
This is a kind of almost useless .
When the garbage collector raises an interrupt , Stop all threads , See which thread is not on the safe point , Wake up it . Let it run to safety .
The safety area
When the thread is not running ( such as Sleep The state or Blocked state ) when , Can't go to a safe place to hang up . The safe area is to solve this matter .
What is a safe area ?
Refers to in a piece of program code , There are no quoted relationship changes , That is, it is safe to interrupt threads anywhere in this area .
How to solve the problem
When a thread enters a safe zone , Will mark themselves in a safe area . At this point, virtual machines don't have to worry about them during garbage collection .
When you go out, you will ask whether the virtual machine has completed the root node enumeration ( Or other stages in the garbage collection process that need to pause the user thread ). If it's done , The thread continues to execute . If not completed , The program to stop , Wait for instructions to leave the safe area .
That's all for the canto .
Keep early hours , take care . The king of early rising wishes you a thousand miles a day
边栏推荐
- leetcode:1200. Minimum absolute difference
- 【TFLite, ONNX, CoreML, TensorRT Export】
- Is investment and finance suitable for girls? What financial products can girls buy?
- byte2String、string2Byte
- Halcon template matching actual code (I)
- 一类恒等式的应用(范德蒙德卷积与超几何函数)
- Codeforces Round #804 (Div. 2)
- 手机 CPU 架构类型了解
- Get data from the database when using JMeter for database assertion
- Time tools
猜你喜欢
1 plug-in to handle advertisements in web pages
调查显示传统数据安全工具在60%情况下无法抵御勒索软件攻击
[loss functions of L1, L2 and smooth L1]
ABAP table lookup program
Sentinel sentinel mechanism of master automatic election in redis master-slave
[yolov3 loss function]
yolov5目標檢測神經網絡——損失函數計算原理
Riddle 1
[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
Principle of persistence mechanism of redis
随机推荐
Check the debug port information in rancher and do idea remote JVM debug
Yolov 5 Target Detection Neural Network - Loss Function Calculation Principle
[cloud native | kubernetes] actual battle of ingress case (13)
Pytorch linear regression
Swift - enables textview to be highly adaptive
MySQL index - extended data
MVVM framework part I lifecycle
Course design of compilation principle --- formula calculator (a simple calculator with interface developed based on QT)
The most comprehensive new database in the whole network, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, flying Book Multidimensional table, heipayun, Zhix
How to clear floating?
7月华清学习-1
Matlab struct function (structure array)
MySQL transaction
Halcon 模板匹配实战代码(一)
Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
Reinforcement learning - learning notes 3 | strategic learning
Complete activity switching according to sliding
leetcode:1200. Minimum absolute difference
Intern position selection and simplified career development planning in Internet companies
Video networkstate property