Java Virtual Machine (1)--java memory Area

Source: Internet
Author: User
Tags float double

Run-time data region

The Java Virtual machine divides the memory it manages into several different data regions during the execution of a Java program. These areas have their own uses, as well as the creation and destruction of time, and some areas exist as the virtual machine process starts, and some areas are built and destroyed depending on the start and end of the user's site.

The memory managed by the Java Virtual machine will include the following run-time data regions, such as

Program counter

1. Program Counter Register is a small memory space that acts as a byte-code and line-number indicator that is executed by the current thread .

2. The bytecode interpreter works by changing the value of this count to select the next byte-code command to execute, branching, looping, jumping, exception handling, thread recovery, and other basic functions need to rely on this counter to complete.

3. Because the multithreading of a Java Virtual machine is implemented in a way that threads take turns switching and allocating processor execution time, at any given moment, a processor (a kernel for a multicore processor) executes only the instructions in the thread, so that it can be restored to the correct location after the thread is switched. Each thread needs to have a separate program counter .

The counters between the threads do not affect isolated storage, which is called "Thread-private" memory.

4. If the thread is executing a Java method, this counter records the address of the executing virtual machine bytecode instruction, which is empty (undefined) if the Natvie method is being executed. The memory area is the only area in the Java virtual machine that does not stipulate any outofmemoryerror conditions.

Java Virtual Machine stack

1. Like the program counter, the Java Virtual machine stack (Java Stacks) is also thread-private, with the same life cycle as the thread.

2. The virtual machine stack describes the memory model that is executed by the Java method: Each release is executed at the same time creating a stack frame , which stores the local variable table, the Operation Stack, the dynamic link, the method exit light information. 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.

2. Java memory is often differentiated into heap memory and stack memory, where the "stack" refers to the current virtual machine stack or the local variable table portion of the virtual machine stack .

3. The local variable table holds the various basic data types known to the compiler (the Boolean char byte short int long float double), the object reference type (possibly the reference pointer that knows the starting address of the object, You may also need only one handle representing the object, or any other location associated with the object, and the ReturnAddress type (the address that points to a bytecode directive).

4.64-bit lengths of long and double data consume 2 local variable spaces (slots), and the remaining data types take up only 1.

5. The memory space required for the local variable table is allocated during compilation, and when entering a method, the method needs to allocate much of the local variable space in the frame is fully deterministic and does not change the size of the local variable table while the method is running.

6. In the Java Virtual Machine specification, two exceptions are specified for this area:

1) If the thread requests a stack depth greater than the virtual machine allows, the Stackoverflowerror exception is thrown

2) If the virtual machine can be dynamically extended (most Java virtual machines can be dynamically extended, but the Java Virtual Machine specification also allows a fixed-length virtual machine stack), an OutOfMemoryError exception is thrown when the extension fails to request enough memory.

Java Virtual Machine (1)--java memory Area

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.