Deep understanding of Java Virtual Machine reading notes---Run-time data regions

Source: Internet
Author: User

Run-time data region

1. Program counter

program Counter Register is a small piece of memory space that can be viewed as the current line
The line number indicator of the byte code executed by the process. The bytecode interpreter works by changing the value of this counter to select the next byte-code instruction that needs to be executed, such as branching, looping, jumping, exception handling, thread recovery, and other basic functions that rely on this counter to complete. Because the multithreading of a Java Virtual machine is implemented in a way that threads rotate and allocate processor execution time , at any given moment, a processor (a kernel for a multicore processor) executes only the instructions in one thread. Therefore, in order for the thread to switch back to the correct execution location, each thread needs to have a separate program counter, the counters between the threads do not affect each other, isolated storage, we call this type of memory area is "thread-private" memory.

2.Java Virtual Machine Stack

The Java Virtual machine stack (Java Stacks) is the same as the program counter and is thread-private, with the same life cycle as the thread. The virtual machine stack describes the memory model that the Java method executes: Each method creates a stack frame (stack frame[1]) to store local variable tables, operand stacks, dynamic links, method exits , and so on. Each method from the call until the completion of the process, corresponding to a stack frame in the virtual machine stack into the stack of the process

The local variable table holds the various basic data types (Boolean, Byte, char, short, int, float, long, double), object references (reference types, which are not equivalent to the object itself) that are known at compile time. It may be a reference pointer to the start address of the object, or it may point to a handle representing the object or other location associated with the object, and the ReturnAddress type, which points to the address of a bytecode directive. "64-bit long and double types of data consume 2 local variable space (slots), and the rest of the data types only occupy one local variable space"

Two exceptions : stackoverflowerror Exceptions are thrown if the thread requests a stack depth that is greater than the allowed depth of the virtual machine If the virtual machine stack can be dynamically extended (most of the current Java virtual machines can be dynamically extended, but the Java Virtual Machine specification also allows a fixed-length virtual machine stack), if the extension cannot request enough memory , it will throw OutOfMemoryError exception.

3. Local Method Stack

  The local method stack is very similar to the virtual machine stack, but the difference between them is that the virtual machine stack executes Java methods (that is, bytecode) for the virtual machine (Native) service. The local method stack is the native method service used by the virtual machine. The language, usage, and data structures used by methods in the local method stack in the virtual machine specification are not mandatory, so the virtual machine can implement it freely. Even some virtual machines, such as sun hotspot virtual machines, combine the local method stack and the virtual machine stack directly.

4.Java Heap

  The Java heap (Java heap) is the largest piece of memory managed by a Java virtual machine. The Java heap is a piece of memory that is shared by all threads and created when the virtual machine is started. The only purpose of this area of memory is to hold object instances where almost all of the object instances are allocated memory. The Java heap is the main area of garbage collector management, so it is often called a "gc heap".

5. Method area

  The method area , like the Java heap, is an area of memory shared by each thread, which is used to store a virtual
Computer-loaded class information, constants, static variables, instant compiler compiled code and other data. Although the Java Virtual machine rules
Van describes a method area as a logical part of a heap, but it has an alias called Non-heap (Not a heap), which is intended to be
This is distinguished from the Java heap.

6. Run a constant-rate pool

  The runtime Constant pool is part of the method area. In addition to descriptive information such as the version, field, method, and interface of the class file, there is also a constant pool (Constant pool Table) that holds the various literal and symbolic references generated during the compilation period, which will be stored in the run-time pool of the class load backward into the method area.

  

Deep understanding of Java Virtual Machine reading notes---Run-time data regions

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.