当前位置:网站首页>JVM runtime data area
JVM runtime data area
2022-07-03 14:00:00 【It's hard to choose a name】
List of articles
The following partitions are logical partitions ;
Class loader will class Static data structures are loaded into lvm in , The runtime data area stores these data ;
jvm Similar to von Neumann computer model :
1、 input device : Class loader , take class File loaded into jvm
2、 Memory : Run time data area
3、 Output devices :jvm Binary instructions output to the underlying operating system
4、 a central processor :( Arithmetic unit 、 controller ):
jvm It is similar to cpu Interaction with memory :
1、 Main memory :
Analogy method area and heap : Thread shared
2、cpu Cache in :
Thread private java Virtual machine stack 、 Native Method Stack 、 Program counter
Method area
The method area is actually a specification , Different java Virtual machines need to be implemented by themselves
jdk1.8 Previous implementations : Forever (PermGen)
jdk1.8 And after : Meta space (PermGen)
What data is stored in the method area ?
1、 String constant pool (jdk1.6 Previously stored in permanent generation ,1.8 And later actually stored in the heap )
2、 Static variables ( Stored in the heap in the meta space )
3、 Class information :( Meta space is stored in direct memory )
Version number 、 Field 、 Method 、 Interface 、 Description information such as parent class
4、 Immediately compiled code ( Such as final Embellished )
5、 Runtime constant pool
The method area is shared by threads
Static constant pool
Static constant pool is relative to runtime constant pool , Of description class Part of the file structure , from Literal and Symbol reference form , After the class is loaded, the static constant pool will be loaded into memory, that is, the runtime constant pool
Literal : Text , String and Final Decorated content
Symbol reference : class , Interface , Method , Fields and other related description information
Runtime constant pool
class , Interface , Method , Fields and other related description information , That is to really put the contents of the document into JVM The memory
String volume pool
String is the most commonly used data type , To reduce memory overhead , A memory area is specially opened for it ( String constant pool ) To store ;
JDK1.6 And previous versions , The string constant pool is located in the permanent generation ( Equivalent to the current method area ).
JDK1.8 And after , The string constant pool is located at Heap In the pile
common problem :String a ="aaaa"; At most one string object is generated
First “aaaa” Will be considered literal , First look in the string constant pool (.equals()), If not found , Create... In the heap “aaaa”
String object , And will “aaaa” The reference of is maintained in the string constant pool ( It's actually a hashTable structure , Deposit key-value
Structural data ), Then return the reference ; If it already exists in the string constant pool “aaaa” References to , Return the reference directly .
String a =new String("aaaa"); Create up to two objects
First “aaaa” Will be considered literal , First look in the string constant pool (.equals()), If not found , Create... In the heap “aaaa”
String object , Then create a... In the heap “aaaa” object , Go back “aaaa” References to
intern()
String s1 = new String("xxx");
String s2 = s1.intern();
System.out.println(s1 == s2); //false
String Medium intern The method is a native Methods , When calling intern When the method is used , If the constant pool already contains one equal to this String
Object's string ( use equals(object) Method determination ), Then return the string in the pool . otherwise , take intern The returned reference points to the current
character string s1(jdk1.6 The version needs to be s1 Copy to the string constant pool )
Pile up
The heap is thread shared
What is stored in the heap ?
1、 Object instances and arrays
2、 The... Of the corresponding class created after the class is loaded java.lang.Class object
java Virtual machine stack
Thread private
1、 The virtual machine stack is a thread execution area , Save the call state of a method in a thread . let me put it another way , One Java The running state of the thread
state , Saved by a virtual machine stack , So the virtual machine stack must be thread private , Unique , Created with the creation of threads
2、 Every method executed by a thread , Is the stack frame in the stack , That is, each method corresponds to a stack frame . Call a method , Will be pushed into the stack
A stack frame ; A method call is completed , It will pop the stack frame out of the stack
For example, method calls :
void a(){
b();
}
void b(){
c();
}
void c(){
}
Stack frame
Thread private
1、 Each stack frame corresponds to a called method , It can be understood as the running space of a method
2、 Each stack frame contains a list of local variables (Local Variables)、 The stack of operands (Operand Stack)、 A reference to the runtime constant pool
(A reference to the run-time constant pool)、 Method return address (Return Address) And additional information
1、 Local variable table : The local variables defined in the method and the parameters of the method are stored in this table
Variables in local variable table cannot be used directly , If necessary , It must be loaded into the operand stack as an operand through related instructions
Use .
2、 The stack of operands : The method of storing operands by pressing and leaving the stack
3、 Dynamic links : Each stack frame contains a reference to the method that the stack frame belongs to in the runtime constant pool , This reference is held to support methods
Dynamic connection in the calling process (Dynamic Linking).
4、 Method return address : When a method starts executing , There are only two ways to exit , One is to encounter the bytecode instruction returned by the method ; One is
Encountered exception , And the exception is not handled in the method body .
Program counter
Thread private
We all know one JVM There are multiple threads executing in the process , And whether the content in the thread can have execution right , It's based on CPU From the dispatch
If a thread A Executing to somewhere , Suddenly lost CPU The enforcement of , Switch to thread B 了 , And then when the thread A And get CPU Executive power
When , How can we continue ? This is the need to maintain a variable in the thread , Record where the thread is executed .
If the thread is executing Java Method , Then the counter records the address of the executing virtual machine bytecode instruction ;
If what is being executed is Native Method , Then this counter is empty .
Native Method Stack
Thread private
1、 If the current thread execution method is Native Type of , These methods will be executed in the local method stack .
2、 Well, if it's in Java Method is called when it is executed native How about the method ?
Associate through dynamic link in stack frame
1、 The stack points to the heap
In the method A a=new A(), Local variable references point to heap objects ( In fact, there may be escape behavior , If this object is used
The scope is only in the method , Then the object will not exist in the heap , convenient GC);
2、 The method area points to the heap
Static variable references point to objects in the heap
3、 Heap points to method area
How does an object know which class it was created from ? When the objects in the heap are stored, some additional information will be stored : such as class point Point to
Class information stored in the method area ; It also stores mark word( Storage lock identification 、gc Age at )、 Example data ( It's the instance variable )、( If it is an array, the length of the array will be stored additionally )、 Alignment filling
边栏推荐
- [技术发展-24]:现有物联网通信技术特点
- Windos creates Cordova prompt because running scripts is prohibited on this system
- IBEM mathematical formula detection data set
- Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
- Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
- Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
- Shell timing script, starting from 0, CSV format data is regularly imported into PostgreSQL database shell script example
- MySQL 数据处理值增删改
- Use and design of Muduo buffer class
- Halcon combined with C # to detect surface defects -- Halcon routine autobahn
猜你喜欢
Error running 'application' in idea running: the solution of command line is too long
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
全面发展数字经济主航道 和数集团积极推动UTONMOS数藏市场
UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
Qt学习25 布局管理器(四)
信创产业现状、分析与预测
Multi person collaborative data annotation based on Baidu brain easydata from scratch
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
jvm-对象生命周期
随机推荐
Complete DNN deep neural network CNN training with tensorflow to complete image recognition cases
Analysis of the characteristics of page owner
Flutter dynamic | fair 2.5.0 new version features
Using registered classes to realize specific type matching function template
There is nothing new under the sun. Can the meta universe go higher?
QT learning 22 layout manager (I)
金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
GoLand 2021.1.1: configure the multi line display of the tab of the open file
Implementation of Muduo asynchronous logging
Field problems in MySQL
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
RocksDB LRUCache
Use vscode to view hex or UTF-8 codes
Windos creates Cordova prompt because running scripts is prohibited on this system
软件测试工作那么难找,只有外包offer,我该去么?
JS new challenges
Halcon combined with C # to detect surface defects -- Halcon routine autobahn
Unable to stop it, domestic chips have made another breakthrough, and some links have reached 4nm
3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)