JVM memory model and memory allocation

Source: Internet
Author: User

1. What is a JVM?
(1) The JVM is a specification for computing devices, a fictional machine that is implemented by simulating various functions on the actual computer.
(2) The JVM contains a set of bytecode instructions, a set of registers, a stack, a garbage-collected heap, and a storage method domain.
(3) The JVM masks information related to the operating system platform, so that Java programs can only generate target code (bytecode) that runs on a Java virtual machine, allowing them to run unmodified on multiple platforms.
When the JVM executes the bytecode, it actually eventually interprets the bytecode as a machine instruction execution on a specific platform.

What is the relationship between 2.JDK, JRE, and JVM?
(1) JRE (Java Runtime Environment), which is the Java platform. All Java programs must be run in the JRE environment.
(2) JDK (Java Development Kit) is a development package that developers use to compile and debug programs. The JDK is also a Java program that needs to run on the JRE.
(3) JVM (Java Virtual machine), which is part of the JRE. It is a fictitious computer, it is realized by simulating various computer functions on the actual computer.
JVM has its own perfect hardware architecture, such as processor, stack, register, etc., also has the corresponding instruction system.
The most important feature of the Java language is running across platforms. The JVM is used to support operating system-independent, cross-platform implementations.

3.JVM principle
(1) The JVM is the core and foundation of Java, a virtual processor between the Java compiler and the OS platform, which executes the bytecode program.
(2) The Java compiler generates bytecode files that the JVM can understand as long as it is oriented to the JVM. Java source files are compiled into bytecode programs that translate each instruction into different machine codes through the JVM
, running through a specific platform.

4. Procedures for JVM execution
1) Load the. class file
2) Manage and allocate memory
3) Perform garbage collection
The JRE (Java Runtime Environment) is a running loop of Java programs that are constructed by the JVM, and is also the environment in which the Java program runs, but he is also an application of an operating system, a process
So he also has his own running life cycle, as well as his own code and data space.
The JVM is at the bottom of the entire JDK and is responsible for interacting with the operating system to shield the operating system environment.
Provides a complete Java runtime environment, so it is also a virtual machine.

The operating system is loaded into the JVM via Java.exe in the JDK,
Use the following 4 steps to complete the JVM environment:
1) Creating a JVM load environment and configuration
2) Loading JVM.dll
3) Initialize JVM.dll and hang bounds to jnienv (JNI call interface) instance
4) Call the JNIEnv instance to load and process the class.

5. The life cycle of the JVM
1) JVM instance corresponds to a separate running Java program It is a process level
A) start. When a Java program is started, a JVM instance is generated, and any one with public static void
The class of the main (string[] args) function can be used as a starting point for the JVM instance to run
b) run. Main () is the starting point for the program's initial thread, and any other thread is started by that thread. There are two types of threads inside the JVM: daemon and non-daemon, main () is non-daemon, the daemon is usually used by the JVM itself, and Java programs can also indicate that the thread they created is a daemon thread
c) extinction. The JVM exits when all non-daemon threads in the program terminate, and the program can use the runtime class or System.exit () to exit if the security Manager allows it.
2) The JVM execution engine instance corresponds to the thread that belongs to the user running the program, which is at the thread level.

JVM memory model and memory allocation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.