当前位置:网站首页>JVM foundation review
JVM foundation review
2022-07-02 23:52:00 【Attacking Xiao Wang 666】
Run time data area
Thread sharing : Heap and method area
Thread exclusive : Virtual machine stack , Native Method Stack , Program counter
The distribution of objects in memory
Object structure includes object header and object body
Object location in memory includes direct pointer and handle pool
How to allocate object memory
Pointer collision : Memory is regular , The pointer moves the distance of the object size to complete the allocation ;
Free list : Memory is not regular , Need to maintain a free list , Record the free location and location size , Find the right space to allocate ;
tlab: Thread allocates buffer locally , In the case of concurrency, each thread pre allocates a small amount of memory in the heap , Which thread wants to allocate memory is allocated in its local buffer , Synchronization locking is not required until a new cache is allocated ;
Object to recycle
Judge life and death first
Reference counting : Object records the reference of other objects , Update when the reference is invalid , Circular references may occur , Cannot be recycled
Accessibility analysis :GCroot Root node enumeration , Using three color marking method , Objects that are not marked are recycled
Recovery algorithm
Mark clear : Clear after marking , Memory fragmentation will occur, but fast , Can't STW
Mark copy : After marking, copy the living object to the unused space , Clean the original space at one time , Copy objects to STW, And waste memory space
Tag to sort out : After marking, move the living object to one place , Clean up all the space behind the pointer of the area where the living object is located , Moving objects also requires STW
Generational collection : Divide the memory area into the new generation and the old generation , Collect according to different strategies , The new generation generally adopts the label Replication Algorithm , It is divided into eden and suivivor( Two ), Default scale 8:1:1, Only enable at a time eden And a piece of survivor, take eden Qu Heyuan survivor Live objects are copied to idle survivor, And clean it at one time ;
In the old days, mark sorting algorithm was generally used ( There are many surviving objects in the old age )
Cenozoic collector ( Are copied with marks )
serial: Single thread
ParNew: Multithreaded collection
Parallel Scavenge The collector : Same multithreading , Controllable throughput
Old age collector
Serial Old The collector : Single thread
Parallel Old The collector :Parallel Scavenge Old age version of collector
CMS: Concurrent low pause , Adopt mark clearing algorithm ( fragmentation )
Initial marker Objects that the root node can be directly associated with
Concurrent Tags Root node enumeration
Final marker Use incremental update to solve the problem of concurrent marking , Record the reference of black to white in the process of concurrent marking , Black turns gray and traverses again
Concurrent elimination Recycling
The most time-consuming concurrent marking and concurrent cleanup are
G1: be based on region Of , Can manage the heap independently , Manage in different ways region, On the whole, it is the tag sorting algorithm , Locally, it is a marker Replication Algorithm , No memory fragmentation , Low pause and high throughput , Pause time model can be established ( Maintain a priority list )
Initial marker
Concurrent Tags
Re label Use the original snapshot to solve the problem of concurrent marking , Record gray objects with white objects disconnected , And rescan
Screening and recovery
Object's memory allocation strategy
Priority is given to eden District Distribution
Large objects directly enter the era ( High cost of replication )
Dynamic age determination : The new generation of objects will be recorded in the object header every time they survive the collection , arrive 15 Backward into old age , Or objects of the same age exceed survivor Half of , Those who are older than or equal to this age are promoted to the elderly generation
Space allocation guarantee mechanism : If risk is allowed , Based on historical experience, try to collect only the Cenozoic ( The old age may be able to accommodate promotion objects ), If it fails, it will still trigger full gc
GC technological process
The new generation GC Under the space allocation guarantee mechanism , If it fails, it will trigger fullGC
Class loading
load verification Get ready analysis initialization
Get the binary stream according to the class name , And load the class information into the method area , create a class object
Verify file formats and specifications
Initialize the class variable to 0
Resolve symbolic references to direct references
Of the execution class init Method , Initialize class variables according to predetermined rules
Parent delegate mechanism
Start class loader
Extended class loader
Application class loader
When performing class loading, delegate to the parent class to load , Don't let the subclass load until the parent class can't load , Only one... Can be loaded through the class loader Object class , Have uniqueness
Break three times
1. Implement the class loader by yourself and inherit classloader, rewrite loadclass Method
2.SPI( Service provider interface ), Such as JDBC, Use thread context loader , The parent class entrusts the child class to load
3.OSGI Achieve modular hot deployment , Reticular , There are horizontal dependencies
边栏推荐
- 数据集-故障诊断:西储大学轴承的各项数据以及数据说明
- Convolution和Batch normalization的融合
- 35 pages dangerous chemicals safety management platform solution 2022 Edition
- What experience is there only one test in the company? Listen to what they say
- 判断二叉树是否为满二叉树
- Hit the industry directly! The propeller launched the industry's first model selection tool
- [error record] the flutter reports an error (could not resolve io.flutter:flutter_embedding_debug:1.0.0.)
- Highly available cluster (HAC)
- 95 pages of smart education solutions 2022
- Bean load control
猜你喜欢

Improvement of RTP receiving and sending PS stream tool (II)

How does win11 turn on visual control? Win11 method of turning on visual control

JDBC練習案例

Interface switching based on pyqt5 toolbar button -2

Bean load control

In February 2022, the ranking list of domestic databases: oceanbase regained its popularity with "three consecutive increases", and gaussdb is expected to achieve the largest increase this month

JDBC教程

Container runtime analysis

容器运行时分析

開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
随机推荐
JSON数据传递参数
Returns the root node of the largest binary search subtree in a binary tree
Ideal car × Oceanbase: when the new forces of car building meet the new forces of database
Realization of mask recognition based on OpenCV
判断二叉树是否为满二叉树
Interface switching based on pyqt5 toolbar button -1
JDBC练习案例
35 pages dangerous chemicals safety management platform solution 2022 Edition
返回二叉树中最大的二叉搜索子树的根节点
万物并作,吾以观复|OceanBase 政企行业实践
MATLAB signal processing [Q & a notes-1]
【OJ】两个数组的交集(set、哈希映射 ...)
What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
[shutter] shutter open source project reference
A single element in an ordered array -- Valentine's Day mental problems
Solution: exceptiole 'xxxxx QRTZ_ Locks' doesn't exist and MySQL's my CNF file append lower_ case_ table_ Error message after names startup
CADD course learning (4) -- obtaining proteins without crystal structure (Swiss model)
采用VNC Viewer方式远程连接树莓派
【STL源码剖析】仿函数(待补充)
How QT exports data to PDF files (qpdfwriter User Guide)