当前位置:网站首页>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
边栏推荐
- Principle of redis cluster mode
- The evolution of mobile cross platform technology
- byte2String、string2Byte
- Thoughts and suggestions on the construction of intelligent management and control system platform for safe production in petrochemical enterprises
- Halcon 模板匹配实战代码(一)
- What is the difference between canvas and SVG?
- Principle of persistence mechanism of redis
- 图像超分实验:SRCNN/FSRCNN
- MySQL stored procedure
- Flutter2 heavy release supports web and desktop applications
猜你喜欢

报错ModuleNotFoundError: No module named ‘cv2.aruco‘

Matlab boundarymask function (find the boundary of the divided area)

Hiengine: comparable to the local cloud native memory database engine
Why do you always fail in automated tests?
你做自动化测试为什么总是失败?

多表操作-自关联查询

Principle of persistence mechanism of redis

Reinforcement learning - learning notes 3 | strategic learning

【TFLite, ONNX, CoreML, TensorRT Export】

Understand kotlin from the perspective of an architect
随机推荐
Uniapp + unicloud + Unipay realize wechat applet payment function
Master the new features of fluent 2.10
Mongodb replica set
JS for loop number exception
[untitled]
无线WIFI学习型8路发射遥控模块
II. Data type
Codeworks 5 questions per day (1700 average) - day 5
Principle of redis cluster mode
Swift - enables textview to be highly adaptive
JS for循环 循环次数异常
yolov5目標檢測神經網絡——損失函數計算原理
The survey shows that traditional data security tools cannot resist blackmail software attacks in 60% of cases
Recyclerview paging slide
abap查表程序
Get data from the database when using JMeter for database assertion
Reading notes of growth hacker
Splunk configuration 163 mailbox alarm
Riddle 1
[loss functions of L1, L2 and smooth L1]