[Interview Question] Structure and Principles of the JVM
Organizing interview questions about the JVM
23-06-27 Complete Unfinished Content 23-07-01 Complete and fill in content
Java Overview
1. Java's Development Philosophy
Write Once, Run Anywhere
-
Aim for a platform-independent language
-
Developed with the focus on being able to run code written in the same language on any operating system (sort of cross-platform)
2. JDK
-
Java Development Kit It is a Java development tool and includes both JRE and JVM. Unlike users, who basically only need to run programs written in Java, developers need to install the JDK. The JDK includes a compiler.
-
Java Runtime Environment The Java Runtime Environment, which includes the Java Class Library, the Java Class Loader, and the JVM. Java code written through the class loader and the library can be combined with the library and run on the JVM.
-
Java Virtual Machine
What is JVM?
-
Java Virtual Machine, Java Virtual Machine.
-
Software that provides an environment for running Java programs.
Java Code → Compiler → Machine Language
Builds the Java Runtime Data Area by allocating memory for the application to run.
Runtime Data Area
-
Heap Area
-
Method Area
The above two areas are shared by all Threads
-
PC Register
-
Native Method Stack
-
Stack Area
The above three areas are created at startup and destroyed at termination for each thread.
Details of each area
1. Heap
- Space where instances of classes, arrays are stored
Garbage Collection * Dynamic memory management system
2. Method
- Space to store the structure of classes, interfaces
3. Stack
-
Similar to C's stack structure, stores local variables and the results of function execution
-
It is responsible for calling and returning functions and has a Stack Frame.
-
What is Stack Frame?
A delimited space for each function that contains the function's call information. Frames are handled in a LIFO fashion If a frame is added when there is no free space → Stack Overflow occurs Pointer method using prologue and epilogue to determine stack return location
4. Native Method Stack
-
Execution stack of methods written in C, CPP
-
Native Method Stack is assigned when executing code
-
May result in StackOverflowError or OutOfMemoryError
-
Can dynamically resize the stack
5. PC Register
-
Each thread has a PC Register
-
Records the address of the instruction when the thread executes the currently assigned instruction
-
Steadily fluctuates the value from instruction to instruction to execute the pointed-to value
Notes
댓글 작성
게시글에 대한 의견을 남겨 주세요.