JVM-runtime data zone and JVM-runtime data Zone

Source: Internet
Author: User
Tags exit in

JVM-runtime data zone and JVM-runtime data Zone
Runtime data Zone

1. Program Counter Register: it is a small memory space and can be seen as a line number indicator of the bytecode executed by the current thread.

--> The bytecode interpreter selects the next bytecode instruction to be executed by changing the value of this counter, the basic functions such as branch, loop, jump, exception handling, and thread recovery all depend on counters.

--> In order to restore the thread to the correct execution position after switching, each thread requires an independent program counter. counters between threads do not affect each other and are stored independently, we call this type of memory region as "thread-private" memory.

--> This memory region is the only region in which the Java Virtual Machine specification does not specify any OutOfMemoryError conditions.

  

2. Java Virtual Machine Stacks (Java Virtual Machine Stacks): it is private to the thread and its lifecycle is the same as that of the thread. The VM Stack describes the Memory Model of Java method execution: each method creates a Stack Frame while executing it) stores information about local variable tables, operand stacks, dynamic links, and method exits. The process from calling to execution of each method corresponds to the process of stack frame loading and exit in the Virtual Machine stack.

--> The local variable table stores various basic data types (boolean, byte, char, short, int, float, long, and double) known during the compilation period, and object references (reference type, it is not the same as the object itself. It may be a reference pointer pointing to the starting address of the object, or it may point to a handle representing the object or other locations related to the object) and returnAddress (pointing to the address of a bytecode instruction ).

--> The memory space required by the local variable table is allocated during compilation. when you enter a method, the size of the local space allocated to the frame in this method is completely determined, the table size of local variables is not changed during method running.

--> Two exceptions occur on the Java Virtual Machine Stack:

A) if the stack depth requested by the thread is greater than the depth allowed by the virtual machine, an StackOverflowError error will be thrown.

B) if the virtual machine can be dynamically expanded (most of the current Java virtual machines can be dynamically expanded, but the Java Virtual Machine specification also allows a fixed-length Virtual Machine stack), if the expansion cannot be applied for enough memory, an OutOfMemoryError is thrown.

3. Native Method Stack: THE Native Method service used by virtual machines. In the virtual machine specification, there is no mandatory rule on the language used by the method in the local method stack. Therefore, a specific virtual machine can freely implement it.

--> StackOverflowError and OutOfMemoryError exceptions are also thrown in the local method stack area.

4. Java Heap: it is the largest memory managed by the Java Virtual Machine. Java heap is a memory area shared by all threads. It is created when the VM is started. The only purpose of this memory area is to store object instances, where almost all object instances allocate memory.

--> Java heap is the main area for managing the Garbage Collector, also known as "GC Heap ".

--> From the perspective of memory recycling, Java heap can be divided into the new generation and old generation, and further divided into Eden space, FromSurvivor space, and tow.vor space.

--> From the perspective of memory Allocation, the Java heap shared by threads may be divided into private Allocation buffers (Thread Local Allocation Buffer, TLAB) for multiple threads ).

--> Java heap can be in physically discontinuous memory space, as long as it is logically continuous.

5. method Area: it is the memory Area shared by each thread. It is used to store data such as class information, constants, static variables, and Code Compiled by the real-time compiler. Alias Non-Heap (Non-Heap)

--> Java Virtual Machine specifications impose very loose restrictions on the method area, without the need for continuous memory space or fixed size or course expansion. You can choose not to implement garbage collection.

--> The garbage collection behavior rarely occurs in the method area. The memory collection goal in this area is to recycle the constant pool and unload the type.

--> When the method area cannot meet the memory allocation requirements, an OutOfMemoryError error is thrown.

6. Runtime Constant Pool: A Part Of The method area.

--> In addition to the description information such as the version, field, method, and interface of the class, the class file also contains the Constant Pool Table ), it is used to store various types of literal and symbolic references generated during the compilation period. This part of content will be stored in the runtime pool of the method area after the class is loaded.

--> In addition to saving the symbolic references described in the class file, the translated direct references are also stored in the constant pool with the form.

--> Another important feature of the runtime constant pool relative to the class file constant pool is dynamic.

--> An OutOfMemoryError is thrown when the constant Pool cannot apply for memory space.

7. direct Memory (Direct Memory): It is not part of the data zone during virtual machine running hours, nor is it the Memory area defined in Java Virtual Machine specifications. However, this part of Memory is frequently used, it may also cause an OutOfMemoryError error.










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.