Java run-time data area summary

table of Contents

FIG runtime data area is divided

Detailed Description

Program Counter

 Java Virtual Machine stack

    Native method stacks

 Java heap

Methods district

Direct Memory


FIG runtime data area is divided

Detailed Description

Program Counter

 

  • Thread private, accessing a bytecode instruction to be executed next, it is an indicator of program control flow, branching, looping, branching, exception handling, and other basic functions thread recovery relies on the complete counter

 Java Virtual Machine stack

 

  •   Thread private, when each method is executed, Java virtual machines are synchronized to create a stack frame [Illustration] (Stack Frame) for storing local variable table, the operand stack, the dynamic linker, and other information for export
  • Often said stack stack here is a virtual machine stack
  •  Required local variable table created during compilation memory space allocated, when entering a method, this method requires much space for local variables allocated in the stack frame is completely determined variable slot determining means (64-bit length long and double take up two variables of data slots, the remainder use only one type of data)
  •  StackOverflowError和OutOfMemoryError

    Native method stacks

  •  To use for the virtual machine local (Native) method service, "Java Virtual Machine Specification" language native method stacks in the methods used, and use the data structure and there is no mandatory requirement
  •  StackOverflowError和OutOfMemoryError

 Java heap

  •   When the virtual machine starts to create shared by all threads, "almost" all object instances are here to allocate memory (due to advances in real-time compiler technology, especially the escape analysis technology increasingly powerful, allocated on the stack, replacing the scalar [Illustration] optimization means has led to some subtle changes quietly)
  • GC heap
  •  "New Generation" "Old Age" "permanent behalf" "Eden space" "From Survivor space" "To Survivor space", the zoning is only part of the common characteristics of the garbage collector or design it
  • And setting the parameters -Xmx -Xms

Methods district

  • Various threads share, "non-heap" (Non-Heap)
  • --- permanent source of generation of call was the HotSpot virtual machine design team chose the generational collector is designed to extend the method area, or use the method to achieve permanent generations area only, so that HotSpot garbage collector can manage like Java heap Like this memory management, eliminating the need to work specifically written to memory management code for the method area
  • [Recovered constant pool and unloading of the type of memory] recycling targets this area is mainly for recycling constant pool and unloading type, in general, the effect of the recovery of the region more difficult to satisfactory, especially the type of uninstall , conditions can be quite harsh, but this part of the recovery area and sometimes indeed necessary
  • [JDK8 start, permanent waste generation element implemented in the local memory space (Meta-space) in place, the type of information is located mainly]
  • [Runtime constant pool]

                1, the Class file content preset constant pool (Constant Pool Table) of
                2, during operation of the new constant may be placed (Intern () method of class String) pool
            -XX: MaxPermSize

Direct Memory

            Not part of the data area of ​​the virtual machine is running, the newly added in JDK 1.4 NIO (New Input / Output) type, based on the introduction of a channel (Channel) and a buffer (Buffer) in the I / O mode, it can Native libraries using directly outside the heap memory allocated, then the stack inside DirectByteBuffer Java objects stored as a reference by this memory to operate. This can significantly improve performance in some scenarios as to avoid the replicated data back and forth to the heap and stack in Java Native

Reference: from "in-depth understanding of the Java Virtual Machine Third Edition"

Published 40 original articles · won praise 12 · views 30000 +

Guess you like

Origin blog.csdn.net/JacksonKing/article/details/104779427