当前位置:网站首页>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
边栏推荐
- Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
- vim区间删行注释
- [shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)
- Highly available cluster (HAC)
- MFC gets the current time
- 请求与响应
- How does win11 turn on visual control? Win11 method of turning on visual control
- Solution: exceptiole 'xxxxx QRTZ_ Locks' doesn't exist and MySQL's my CNF file append lower_ case_ table_ Error message after names startup
- RTP 接发ps流工具改进(二)
- Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
猜你喜欢
Go basic data type
35页危化品安全管理平台解决方案2022版
MySQL基础
CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)
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
Practical series - free commercial video material library
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
接口差异测试——Diffy工具
Create an interactive experience of popular games, and learn about the real-time voice of paileyun unity
What experience is there only one test in the company? Listen to what they say
随机推荐
How QT exports data to PDF files (qpdfwriter User Guide)
What if win11 can't turn off the sticky key? The sticky key is cancelled but it doesn't work. How to solve it
How to maintain the brand influence of clothing enterprises
返回二叉树中最大的二叉搜索子树的大小
Mapper代理开发
容器运行时分析
Mapper agent development
35 pages dangerous chemicals safety management platform solution 2022 Edition
[OJ] intersection of two arrays (set, hash mapping...)
Returns the maximum distance between two nodes of a binary tree
95 pages of smart education solutions 2022
Maybe you read a fake Tianlong eight
Container runtime analysis
Open Source | Wenxin Big Model Ernie Tiny Lightweight Technology, Accurate and Fast, full Open Effect
php 获取真实ip
开源了 | 文心大模型ERNIE-Tiny轻量化技术,又准又快,效果全开
Dishes launcher small green program and directory management (efficiency tool)
返回二叉树中最大的二叉搜索子树的根节点
C MVC creates a view to get rid of the influence of layout
顶级 DevOps 工具链大盘点