In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what is the principle of JVM", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the principle of JVM" this article.
I. the principle of JVM
Java virtual machine is the cornerstone of Java platform, which solves the independence of hardware and operating system. The JVM of different platforms (Windows,Linux and MacOS) is different, but they all provide the same interface. Virtual machines can be divided into system virtual machines and program virtual machines. System virtual machines, such as VMware and VirtualBox, are completely isolated from physical resources. The Java virtual machine is a program virtual machine, which contains a set of instructions and operates on different memory regions at run time, which are called Java bytecode instructions in JVM.
II. The structure of JVM
The basic structure of JVM is shown in the following figure:
The Java file in the figure generally refers to all the programming language files built on the Java virtual machine, such as Groovy, Scala, Kotlin and so on. JVM is not associated with any of these languages, but rather compiles those languages into the binary format of "Class files" using javac. The Class file contains some other information about the JVM instruction set and symbol table.
2.1 Class loading Subsystem
Responsible for storing the class bytecode file in the memory of the method area, verifying, transforming, parsing and initializing the data, and finally forming a Java type that can be directly used by the virtual machine.
2.2 execution engine
Responsible for executing the bytecode of the virtual machine, JVM establishes its own instruction set and architecture, inputs the bytecode file and outputs the execution results.
2.3 Program counter
Is a small memory space that can be thought of as a bytecode line number indicator executed by the current thread, and each thread has a separate program counter. In the virtual machine conceptual model, the bytecode interpreter works by changing the value of the counter to select the next instruction to be executed. When a CPU time slice switch occurs, the program counter ensures that the thread can recover to the correct execution position after it has regained the CPU time slice.
If the current method is the Java method, the value of the program counter is the address of the executing virtual machine bytecode instruction; if it is the Native method, it is empty
2.4 Virtual Machine Stack
Is private to the thread and is the same as the life cycle of the thread. The virtual machine stack also contains multiple stack frames, and a stack frame is created for each method run, which is used to store local variables, operation stacks, method return values, and so on. From the call to the completion of the execution of each method, there is a stack frame corresponding to the process from the stack to the unstack in the java stack.
The local variable table stores a variety of basic data types, object reference addresses and returnAddress. Therefore, the memory space needed by the local variable table can be allocated at the compilation time. When entering a method, the size required by the method in the stack frame is determined and does not change during operation
2.5 Local method stack
The local method stack acts like a virtual machine stack, except that the virtual machine stack serves to execute Java methods, while the local method stack serves the native methods used by the virtual machine
2.6 heap
The heap is created when the virtual machine starts and is an area of memory shared by all threads. Almost all objects are placed on the heap, and the heap becomes the main area of garbage collection. Before JDK1.8, the heap can be divided into Cenozoic and old age, in which the Cenozoic can be subdivided into three regions: Eden,From and To.
Starting with JDK1.8, the permanent generation is transferred from heap memory to local memory
2.7 method area
The memory area shared by each thread is used to store class information, constants, static variables, code compiled by the compiler, and so on. The method area on the HotSpot virtual machine corresponds to the permanent generation in the figure above. This area does not require contiguous memory areas, and the main goal of GC recycling is to unload constant pools and types.
The above is all the contents of this article "what is the principle of JVM?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.