java memory partition

Program counter (thread private):

        Features: Created when the thread is created, and its value is undefined when the native method is executed.

Virtual machine stack (thread private):

        Features: (stack memory) Execute java method services for the virtual machine: create a stack frame when the method is called --> local variable table --> local variables, object references

                    A StackOverFlowError occurs if the thread's requested stack depth exceeds the depth allowed by the virtual machine lock. -Xss specifies the maximum size of the stack

                    The virtual machine stack can be dynamically expanded. If it expands to the point where it cannot apply for enough memory, OOM will occur.

Native method stack (thread private):

        Features: The java virtual machine stack is for the virtual machine to execute java methods. The local method stack serves the Native methods used by the virtual machine for execution.

                The Java virtual machine has no lightweight provisions for the use of native method stacks and data structures. SunHotSpot combines the Java virtual machine stack and the native method stack into one.

                Will throw StackOverFlowError and OutOfMemoryError

The java heap, the memory heap (shared by threads):

        Features: Shared by all threads, created when the java virtual machine starts, almost all object instances are placed on the heap

                    The main area of ​​GC management

                    Physical discontinuity. Logically continuous and can be dynamically expanded. Throws OutOfMemoryError when unable to extend

Method area (thread sharing):

        Features: Used to store class information that has been loaded by the virtual machine, constant. Static variables, that is, the data of the code compiled by the compiler

                The SunHotSpot virtual machine calls the method area the permanent band

Runtime constant pool (part of method area):

        Features: Restricted by the method area, throws OutOfMemoryError

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324930404&siteId=291194637