In-depth understanding of Java Virtual Machines Learning notes (i)

Source: Internet
Author: User

The JDK is a minimal set of environments that support Java Program development, and theJRE is a standard environment for Java programs to run. The JRE is part of the JDK.

The Java 1.0 version was born in 1995 , the virtual machine used by the Sun classisc vm, which is no longer in use. JDK1.3 ,theHotSpot VM becomes the default virtual machine. Other more famous Java virtual machines include JRockit,J9 , and so on.

the java.util.concurrent package in JDK1.5 implements a coarse-grained concurrency framework,JDK1.7 The Java.util.concurrent.forkjoin package is an important extension of the framework. fork/join is a classic way of dealing with parallelism, making it easy to take advantage of multiple CPUs, using fork/join mode, We can successfully transition to a multi-nuclear age.

  

In Java 8 , support for Lamda will be provided, functional programming will be well supported, and a key feature of functional programming is the suitability of parallel operations.

Because of the expansion of the pointer and the various data types to align the filler, the efficiency of the Java virtual machine is more efficient than the three-bit Java virtual machines are inefficient. Enterprise-class java EE often needs more than 4GB of memory, many still use virtual cluster mode in the four-bit virtual machine running, the urgent need support for virtual machines.

When you run a Java program, the Java virtual machine divides the memory it manages into several different regions. These areas have their own uses, as well as the creation and destruction times. Accordingto the Java virtual Machine Specification (Java SE7 edition ),java The virtual machine will divide the memory it manages into several areas:

  

  

We can see that the method area and the heap in the runtime data area are shared by all the threads, and the rest, such as the virtual machine stack, the local method stack, and the program counter, are isolated between threads.

The program counter, which can be seen as the line number indicator of the byte code executed by the current thread. The bytecode interpreter selects the next byte-code instruction to be executed by the value in the program counter. Loops, jumps, and exceptions all need to rely on program counters to complete.

When executing multithreaded programs, each thread needs a separate program counter to ensure that the thread switches back to the correct execution location.

This zone is the only one in the Java Virtual machine specification that does not specify outofmemoryerror .

Java Virtual machine stack ,java virtual machine stack is thread-private, its life cycle and thread are the same. the Java virtual machine stack contains information such as: local variables, operand stacks, dynamic links, method exits, and so on.

There are 2 exceptions defined for this memory in the Java virtual machine , which will be thrown if the thread requests a stack depth greater than the virtual machine allows stackoverflowerror exception, if the virtual machine stack cannot request enough memory, it will throw OutOfMemoryError exception.

The local method stack, the local method stack, and the Java virtual machine stack are similar, except that the local method stack serves the Native method of the Java virtual machine . Many virtual machines , such as hotspots , directly merge the local method stack with the Java virtual machine stack.

Java Heap, The purpose of the Java heap is to hold object instances. java Heap is the main area of garbage collection Manager management,java heap can be divided into Cenozoic and Laosheng generation, and then the specific point can be divided into Eden space, from Survivor,toSurvivor and so on.

The Java heap can be a physically disjoint space, as long as it is logically contiguous.

Java Heaps in mainstream Java virtual machines are mutable, controlled by -xmx and -xms .

OutOfMemoryError exceptions are also thrown when memory cannot be requested on the Java heap .

The method area , like the Java heap, is also an area of memory shared between threads. The method area is mainly used for storing data such as class information, constants, static variables and so on.

for a HotSpot virtual machine, the method area can be seen as an eternity generation. But not the data into the method area will not be recycled, method area recycling is mainly the collection of constant pool and type of unloading.

Static variable, which retains the last value each time it is assigned to the value · is a class variable that can be modified by a class or object , and final is a constant, assigned once, and cannot be re-assigned again .

  

In-depth understanding of Java Virtual Machines Learning notes (i)

Related Article

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.