Java Memory Architecture Summary of Java JVM

Source: Internet
Author: User

The JVM system mainly consists of the following parts:

class loader, execution engine, memory area, local method call.

The memory area generally refers to the run-time data area, below summarizes what content and function are stored in the following sections:

Program counter (PC Register):

Thread Private. is a small piece of memory that can be seen as the line number indicator of the byte code executed by the thread. The bytecode interpreter works by changing the value of this counter to select the next byte-code instruction that needs to be executed, and the basic functions such as branching, looping, exception handling, thread recovery, and so on, need to rely on this counter to complete. Each thread can revert to the correct execution location after switching, each thread has its own program counter, each thread is private. Into the executing Java method, logging the address of the virtual machine bytecode instruction being executed, or null if the native method is being executed. There are no areas where any outofmemoryerror conditions are specified.

Java Virtual machine stack:

Thread Private. Describes the memory model that Java methods perform: Each method creates a stack frame to store information such as 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. is the stack in the "Heap" and "stack" that we often divide, or the partial variable table.

The local variable table holds the basic data types and reference types known to the compiler. The memory space required for a local variable table is allocated during compilation, and when entering a method, this method needs to allocate much of the local variable space in the stack to be fully deterministic.

Local method Stack:

Similar to the virtual machine stack, the virtual machine stack is implemented as a Java method (bytecode) service, while the local method stack is the native method service used by the virtual machine. Some virtual machines into sun Spot have merged this part with the virtual machine stack.

java heap:

Thread sharing. is the largest piece of memory managed by a Java virtual machine. Created when the virtual machine is started. The only purpose is to hold object instances, and almost all object instances are allocating memory. is the main area of the garbage collector management and is also a "GC heap". The garbage collector basically uses the Generational collection algorithm, so the Java heap can also be subdivided into: the new generation and the old age; the finer points can be divided into Eden space, from Survivor space, to survivor space and so on. Physical discontinuity, logical continuity. The fixed size can also be extended.

Method Area:

Thread sharing. Stores data such as class information, constants, static variables, instant compiler compiled code, etc. loaded by a virtual machine. The JVM specification describes it as a logical part of the heap, but has an individual name--not a heap--that distinguishes it from the Java heap.

To run a constant-rate pool:

Part of the method area, class file in addition to the class version, fields, methods, interfaces and other descriptive information, there is also a constant pool, for the compilation period generated by a variety of literal and symbolic references, this part of the class load in the method area of the run-time constant pool storage.

Direct Memory:

is not part of the form data region, nor is it defined in the JVM specification. Because this part of the memory is frequently used, so also pay attention to. The introduction of the NIO class in JDK1.4 introduces the I/O mode based on channel and buffer, which can allocate out-of-heap memory directly using the native library. It then operates as a reference to this memory through a Directbytebuffer object stored in the Java heap. This can significantly improve performance in some scenarios, thus avoiding copying data back and forth in the Java heap and the native heap.

Java Memory Architecture Summary of Java JVM

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: 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.