Java JVM Operating mechanism principle

Source: Internet
Author: User

A: Introduction

in Learning before the Java virtual machine, that is, before the Jvm , I think we can take the problem to learn, so that we can learn more than to get!

1. What is aJava virtual machine (Jvm)?  
What is a 2.Java virtual machine for?  
3.Java Virtual Machine What does its architecture look like?  
What role does a 4.Java virtual machine play in a job?  
5.Java Virtual Machine in the run-time data area?

II:JVM Basic Concepts

Java virtual machine (JVM) is an imaginary computer that can run java Code

A Java virtual machine consists of a set of bytecode instructions, a set of registers, a stack, a garbage-collected heap, and a storage method domain.

in understanding Before the JVM , if you are interested, you can first understand the Java heap and stack, you can view the previous article:
The difference between Java heap and stack http://blog.csdn.net/u011546655/article/details/52170470

Three:JVM

we all know that. Java source files, through the compiler, can produce the corresponding . Class file, which is the bytecode file, and the bytecode file is passed through the interpreter in the Java virtual machine, which is the byte code instruction set in all the Java virtual machines. ... . Compiling machine code on a specific machine

This is also the following:

1.Java source file -- compiler -- byte-code file

2. byte-code file -->jvm--> Machine code

The interpreter for each platform is different, but the virtual machines that are implemented are the same. That 's why Java can cross the platform .

When a program runs a program from the beginning, the virtual machine begins to instantiate. Multiple virtual machine instances are present when several programs are started. Program exits or shuts down. The virtual machine instance dies. Data cannot be shared between multiple virtual machine instances.

Four: architecture of the JVM

the architecture of the JVM is in:

1. Garbage Collector

garbage collector (also known as GC): is responsible for reclaiming useless objects in memory (as the Earth knows), that is, these objects do not have any references, it will be considered as: garbage, it was killed.

2. Class loading Subsystem

a name, you know, it must be used for the operation of our compiled good . Class file System, he functions as follows:

V positioning and importing binary class files

V Verify the correctness of the import class

V Initialize memory for class allocation

V Help parsing symbol references

3. Execution engine (executionengines)

An instruction that executes a package in a method that loads a class, that is, a method

4. Operation Area Data

such as: Virtual machine memory or JVM Memory, flushes the entire computer memory to open up a piece of memory storage JVM needs to use objects, variables, etc., the runtime data is divided into a lot of cells, respectively: Method area, virtual machine stack, local method stack, heap, program counter

Five:Jvm Runtime data area

1. Program Counter

The current thread executes the signal indicator of the bytecode, the thread is private, its life cycle and thread the same branch, loop, jump, exception handling, thread recovery and other basic functions need to rely on this counter to complete.

2. Virtual Machine Stack

The Java virtual machine stack describes the memory model that is executed by the Java method, which differs from The local method of native: Each method is executed with a stack frame created at the same time ( Stack Frame ) is used to store information such as local variable tables, action stacks, action links, method exits, and so on.

The thread is private, the life cycle and the thread are the same, there are separate counters, each with no impact.

Each method is called until the completion of the process, corresponding to a stack frame in the virtual machine stack from the stack to the process of the stack.

3. Local method Stack

is similar to the virtual machine method stack, but the local method stack is a service to the virtual machine the Native method service to use

4. Local Method Area:

just perform Native method.

If the memory shortage in this area is also thrown Stackoverflowerror and outofmemoryerror exceptions.

Six: Heap

this area of the heap is The largest, applied object and data in the JVM is present in this area. This area is also shared by threads. is also the GC 's main recycling area.

In fact, this is what we listen to more: Java (GC) Garbage collector

for space reasons, I will focus on the following in the next article: Java? principle Analysis of GC collector

Java JVM Operating mechanism principle

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.