当前位置:网站首页>[JVM] detailed description of the process of creating objects
[JVM] detailed description of the process of creating objects
2022-07-02 02:49:00 【A Xiaobing】
Preface
Development process , We must often create an object , Don't say you don't know , To create an object, you should first think of new, and you? new It's cool , But you know you are so new once , How did you create this object ? Do you know the principle ? It doesn't matter if I don't know , Next, let's explain it in combination with the figure
Detailed steps
1、JVM Received our new Instructions
First, I will check the quilt new Whether this parameter of can locate the symbolic reference of this class in the constant pool , And also check whether the class referenced by this symbol has been loaded 、 analysis 、 initialization
2、 Check whether the current class has been initialized
If this class has been initialized , Then proceed to the following serial number 3 Steps for , Otherwise, you need to load the class first
3、 Allocate memory
After the class load verification passes , Then the memory allocation of new objects will be carried out
4、 Confirm the memory size
The memory size required for object generation can be determined when the class is loaded , Allocating space for an object is equivalent to transferring a certain amount of memory from Java Divide it up in the heap
5、 Allocated memory size
There are two main situations
(1)JVM The memory is regular , All memory used is put aside , The free memory is on the other side , Put a pointer in the middle as an indicator of the dividing point , In this case , It is easier to allocate memory , At that time, you just need to put the pointer 2 Point to the free memory and move a distance equal to the size of the object , This is what is often said “ Pointer collision ”
(2)JVM Memory of is irregular , It is equivalent to that the used memory and unused memory are staggered with each other , In this case, there is no way to achieve pointer collision , So what should we do ? Only one table needs to be maintained , To record the information available in memory , When allocating, find enough space in the list to allocate to the object instance and update the memory state in the record table
6、 initialization
After the above memory space is allocated ,JVM You need to initialize the memory space to 0, There are also steps in the picture TLAB, If you use TLAB, You can go to TLAB The initialization can be carried out during allocation
7、 Basic information settings
JVM Make the necessary Settings for the object , For example, hash code 、 Memory address and other information
8、 Generate executable objects
Here we need to execute init Method , Initialize the object according to the initialization operation set in the program , At this time, an object is really initialized , Created a virtual machine executable java type
边栏推荐
- JS slow animation
- Questions d'entrevue
- Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
- Start from scratch - Web Host - 01
- es面試題
- What is the difference between an intermediate human resource manager and an intermediate economist (human resources direction)?
- STM32__ 05 - PWM controlled DC motor
- [staff] the direction of the symbol stem and the connecting line (the symbol stem faces | the symbol stem below the third line faces upward | the symbol stem above the third line faces downward | the
- New programmer magazine | Li Penghui talks about open source cloud native message flow system
- Yyds dry goods inventory accelerating vacuum in PG
猜你喜欢
Jvm-01 (phased learning)
Baohong industry | four basic knowledge necessary for personal finance
query词权重, 搜索词权重计算
Query word weight, search word weight calculation
Special symbols in SAP ui5 data binding syntax, and detailed explanation of absolute binding and relative binding concepts
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)
Remote connection to MySQL under windows and Linux system
Feature query of hypergraph iserver rest Service
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
Comparative analysis of MVC, MVP and MVVM, source code analysis
随机推荐
2022-2028 global deep sea generator controller industry research and trend analysis report
Remote connection to MySQL under windows and Linux system
Systemserver service and servicemanager service analysis
实现一个自定义布局的扫码功能
Learning notes of software testing -- theoretical knowledge of software testing
设置状态栏颜色
What is the difference between an intermediate human resource manager and an intermediate economist (human resources direction)?
Baohong industry | 6 financial management models at different stages of life
Provincial election + noi Part IV graph theory
Infix expression to suffix expression (computer) code
Leetcode question brushing (10) - sequential question brushing 46 to 50
Websocket + spingboot realize code scanning login
Which brand of sports headset is better? Bluetooth headset suitable for sports
QT使用sqllite
Unit · elementary C # learning notes
How to create an instance of the control defined in SAP ui5 XML view at runtime?
Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
Vsocde has cli every time it is opened js
What are the characteristics of common web proxy IP
Baohong industry | what misunderstandings should we pay attention to when diversifying investment