Java Virtual Machine Notes (a)

Disclaimer: This article is a blogger original article, please indicate the source. Welcome to public concern number: Java Notes Share (xiaosen_javashare) https://blog.csdn.net/qq_36447151/article/details/87939835

JDK and JRE difference

1, the general Java programming language, java virtual machine, java API library three parts collectively referred to as JDK (Java Development Kit), JDK for Java programs to support the development of a minimal environment.

2, Java API class libraries in Java SE API subset of the Java virtual machine and the two parts are collectively referred to as the JRE (Java Runtime Environment), JRE supports standard Java environment to run.
Content java technology system included

Java virtual machine memory area

First, the program counter

Thread can be seen as the current byte code executed by the line number indicator. Thread private memory. It is not the only area of ​​a memory leak in a Java virtual machine memory area.

Two, Java virtual machine stack

Java Virtual Machine stack Java memory model described method performed: each method creates a stack frame while performing for storing local variable table information, the operand stack, the dynamic link stack, the method exports. Java virtual machine thread stack is a private, life cycle and the same thread.

Java Virtual Machine stack table of local variables: storage of all kinds of basic data types compile knowable, reference types (reference) and runAddress type. Local variable table memory space needed to complete the memory allocation during compilation, during operation of the method does not change the size of the local variable table.

Exception:

1) StackOverflowError: the depth of the stack is greater than the virtual machine thread requests allowed depth.

2) OutOfMemoryError: not enough memory to apply when expanding.

Third, the native method stacks

Similar to the Java virtual machine stack, thread private, StackOverflowError and throws an OutOfMemoryError.

Java virtual machine stack difference is that native method stacks Native method is to use a virtual machine services, Java Virtual Machine stack for the Java virtual machine to perform service method.

Four, Java heap

Storage object instance, is shared by all threads, created when the virtual machine starts. The main area also known as the Java heap GC heap, the garbage collector management.

Java heap can be broken down as follows: the new generation and the old era. Eden space can also be divided, From Survivor space, To Survivor space.

If there are no instances in the heap memory allocation is completed, and can no longer expand, it will throw an OutOfMemoryError

Fifth, the method area

Class information is used to store the virtual machine has been loaded, constants, static variables, the time compiler to compile the code and other data. Is the thread shared area.

And do not require continuous java heap memory as a fixed size and can be selected and can be extended. The difference is that you can choose not to implement garbage collection, the main memory recovery goal for this area is the recovery of the constant pool and unloading of types.

When the method of memory allocation area can not meet demand, it will throw an OutOfMemoryError

Sixth, the runtime constant pool

The method is part of the region, and for storing various literal compile generated reference symbols, this part is brought to run in the methods of classes loaded zone time constant storage pool. The dynamic nature, the runtime can also store a new constant into the pool. Also if you can not allocate memory will throw an OutOfMemoryError.

Seven, direct memory

Not part of the virtual machine operating data area. Native NIO class libraries can be used directly outside the heap memory allocated, then the object is stored in the Java heap DirectByteBuffer as this memory reference operation, avoids the Java heap and stack Native replicate data. It will throw an exception OutOfMemoryErrory


Welcome to public concern number:
No micro-channel public

Guess you like

Origin blog.csdn.net/qq_36447151/article/details/87939835