当前位置:网站首页>[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
边栏推荐
- trading
- 【带你学c带你飞】2day 第8章 指针(练习8.1 密码开锁)
- Stdref and stdcref
- QT实现界面跳转
- 使用 useDeferredValue 进行异步渲染
- Feature query of hypergraph iserver rest Service
- The wave of layoffs in big factories continues, but I, who was born in both non undergraduate schools, turned against the wind and entered Alibaba
- [road of system analyst] collection of wrong topics in enterprise informatization chapter
- Addition without addition, subtraction, multiplication and division (simple difficulty)
- Connected block template and variants (4 questions in total)
猜你喜欢

Golang configure export goprivate to pull private library code

Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field

LeetCode刷题(十)——顺序刷题46至50

Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing

2022-2028 global wood vacuum coating machine industry research and trend analysis report

Feature query of hypergraph iserver rest Service

2022-2028 global nano abrasive industry research and trend analysis report

After marriage

QT implementation interface jump

Summary of some experiences in the process of R & D platform splitting
随机推荐
The video number will not be allowed to be put on the shelves of "0 yuan goods" in the live broadcasting room?
Après le mariage
Redis cluster
【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
JVM面试篇
essay structure
What is the function of the headphone driver
how to come in an investnent bank team
Mathematics in Sinorgchem: computational geometry
2022-2028 global aluminum beverage can coating industry research and trend analysis report
How to hide the scroll bar of scroll view in uniapp
Divorce for 3 years to discover the undivided joint property, or
MongoDB非关系型数据库
What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
2022安全员-C证考试题及模拟考试
How to turn off the LED light of Rog motherboard
Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
Which brand of sports headset is better? Bluetooth headset suitable for sports
C write TXT file
