当前位置:网站首页>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
边栏推荐
- 公司里只有一个测试是什么体验?听听他们怎么说吧
- Create an interactive experience of popular games, and learn about the real-time voice of paileyun unity
- How QT exports data to PDF files (qpdfwriter User Guide)
- List of major chip Enterprises
- Integration of revolution and batch normalization
- 【OJ】两个数组的交集(set、哈希映射 ...)
- 万物并作,吾以观复|OceanBase 政企行业实践
- CADD course learning (4) -- obtaining proteins without crystal structure (Swiss model)
- What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
- yolov5train. py
猜你喜欢

采用VNC Viewer方式遠程連接樹莓派

开源了 | 文心大模型ERNIE-Tiny轻量化技术,又准又快,效果全开

The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north

What can I do after buying a domain name?

Realization of mask recognition based on OpenCV

Three solutions to frequent sticking and no response of explorer in win11 system

Optimization of streaming media technology

Container runtime analysis

Convolution和Batch normalization的融合

Highly available cluster (HAC)
随机推荐
Yolox enhanced feature extraction network panet analysis
Improvement of RTP receiving and sending PS stream tool (II)
Top Devops tool chain inventory
第三方支付功能测试点【杭州多测师_王sir】【杭州多测师】
leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
Convolution和Batch normalization的融合
C# MVC创建一个视图摆脱布局的影响
Codeforces Round #771 (Div. 2)---A-D
Interpretation of new plug-ins | how to enhance authentication capability with forward auth
【OJ】两个数组的交集(set、哈希映射 ...)
Use of cocospods
Agnosticism and practice makes perfect
cocospods 的使用
ArrayList analysis 2: pits in ITR, listiterator, and sublist
采用VNC Viewer方式远程连接树莓派
Returns the maximum distance between two nodes of a binary tree
MySQL基础
公司里只有一个测试是什么体验?听听他们怎么说吧
Data set - fault diagnosis: various data and data description of bearings of Western Reserve University
Happy Lantern Festival, how many of these technical lantern riddles can you guess correctly?