On the Java heap, stack, method area

  • Stack (Stack)

    1. thread stack is private, its life cycle and the same thread.

    2. Each method will open up in the implementation of a stack area, creating a stack frame (Stack Frame).

    3. The stack frame information for storing local variable table, the operand stack, and a method for dynamic link export.

    4. The local variable table stores two types of data:

    basic data types : Boolean, byte, Short, int, char, a float, Long, Double.

    reference data types : the referenced object, not the object itself, such as String s = new String (), stored in the local variable table is s, and the new String () is located in the heap. Here s is a reference to an object pointer to the starting address.

    The call to the end of each method, corresponding to the virtual machine process on the stack from the stack to the stack in the stack frame.


  • Heap (Heap)

    1. The heap is shared by all threads of memory area, created when the virtual machine starts, the virtual machine is the largest block of memory.

    1. thread heap is shared, is the largest virtual machine memory block is created when the virtual machine starts.

    2. used to store objects, almost all objects are here to allocate memory.

    ( Since the JIT compiler escape analysis and development of mature technologies, the stack distribution, scalar replacement such that not all objects are allocated in the heap. )

    3. heap is the main area managed by the garbage collector, sometimes also called GC堆.

    4. The heap memory is not continuous, slow physically, but logically continuous dispensing flexible, scalable.


  • Method region (Method Area)

    1. The method area known as static area, is the thread shared memory area.

    2. The class information is used to store the virtual machine is loaded, character constants, static variables, static methods.

    3. A content is loaded or only immutable. (Class information, character constants and static variables.)

    4. Although the official method area described as a logical part of the heap, but he was not entirely true sense of the heap,

    He also has a name Non-Heap. And its purpose is to distinguish the stack.


  • Runtime constant pool (Runtime Constant Pool Table)

    1. The method is part of the region.

    2. The runtime constant pool dynamic nature, also during operation of the new constant into the constant pool may be, for example Inter class String () method.


  • In the final say

    1. The code word is not easy, welcome attention and forwarding, please indicate the source, thanks for the support.

    2. The part reference from "in-depth understanding of java virtual machine," a book.

Guess you like

Origin www.cnblogs.com/coding-996/p/12006464.html