当前位置:网站首页>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
边栏推荐
- Pytorch linear regression
- [HDU 2096] 小明A+B
- Basic operations of MySQL data table, addition, deletion and modification & DML
- Application of a class of identities (vandermond convolution and hypergeometric functions)
- Riddle 1
- July Huaqing learning-1
- Deep discussion on the decoding of sent protocol
- Halcon 模板匹配实战代码(一)
- 只是巧合?苹果 iOS16 的神秘技术竟然与中国企业 5 年前产品一致!
- SENT协议译码的深入探讨
猜你喜欢

Use and install RkNN toolkit Lite2 on itop-3568 development board NPU

Redis cluster (master-slave) brain crack and solution

Get all stock data of big a

Thoughts and suggestions on the construction of intelligent management and control system platform for safe production in petrochemical enterprises

Read and understand the rendering mechanism and principle of flutter's three trees

多表操作-自关联查询

强化学习-学习笔记3 | 策略学习
![[loss functions of L1, L2 and smooth L1]](/img/c6/27eab1175766b77d4f030b691670c0.png)
[loss functions of L1, L2 and smooth L1]

Linux Installation and deployment lamp (apache+mysql+php)

Principle of persistence mechanism of redis
随机推荐
MySQL multi table operation
Mongodb replica set
Matlab label2idx function (convert the label matrix into a cell array with linear index)
How can beginners learn flutter efficiently?
Application of a class of identities (vandermond convolution and hypergeometric functions)
ACID事务理论
Principle of persistence mechanism of redis
7月华清学习-1
多表操作-子查询
一类恒等式的应用(范德蒙德卷积与超几何函数)
什么是数字化存在?数字化转型要先从数字化存在开始
1 plug-in to handle advertisements in web pages
Hash tag usage in redis cluster
Mmclassification training custom data
byte2String、string2Byte
MySQL storage engine
Matlab boundarymask function (find the boundary of the divided area)
Open3d European clustering
Image hyperspectral experiment: srcnn/fsrcnn
一款新型的智能家居WiFi选择方案——SimpleWiFi在无线智能家居中的应用