Java virtual machine memory area model

Thread private memory area of ​​the program counter (Program Counter Register) The program counter is a small memory space, it can be regarded as the row number designator bytecode executed by the current thread. Each thread has its own program counter, if the thread is executing a Java method, then the counter records a virtual machine bytecode instruction address being executed, if progress is Native method, the program counter empty (Undifined). This memory area is the only one not provide for any situation in the region OutOfMemoryError Java Virtual Machine Specification. Virtual Machine stack (VM Stack) virtual machine thread stack is private, it describes the Java memory model method performed: Each method creates a stack frame (Stack Frame) while performing for storing local variable table, the operation the operand stack, dynamically linked, and other information for export, each method call until completion of the procedure, it corresponds to a process stack frame is pushed and popped in a virtual machine stack. VM stack frame, the local variable table is relatively well known, which is usually called "stack", the required memory space allocated local variable table created during compilation, when entering a method that requires the how the stack frame allocated local variable space is well defined, the method does not change during operation of the size of the local variable table. Virtual Machine stack has two exceptions: StackOverflowError: thread stack depth is greater than the requested virtual machine allowable depth, especially when the recursive method calls OutOfMemoryError: virtual machine thread stack space requirements can not be met by the application, even after the dynamic expansion remains can not be met, it will lead to an OutOfMemoryError native method stacks (native method stack) native method stacks and stacks similar to the virtual machine, but to serve the local method, some virtual machines combined these two areas. Native method stacks in case an exception is thrown with the same virtual machine stack. Shared memory area heap (Heap) In general, the heap is the largest piece of memory in the Java virtual machine management, shared by all threads, created when the virtual machine starts, heap role is to store an object instance. Heap is the main area managed by the garbage collector, and therefore often also referred to as "GC heap." From the perspective of the memory recovery, due to current collector basically using generational collection algorithm, So heap can also be subdivided into: the new generation and the old era. Continue segmentation can be divided into: Eden space, From Survivor space, To Survivor space, memory allocation from the point of view, the contribution of the heap threads can also be divided into multiple threads private allocate a buffer u (Thread Local Allocation Buffer, TLAB). Stack may be discontinuous on the physical space, as long as the can is logically continuous, and -Xms -Xmx parameter controls the maximum and minimum size of the heap. Space the size of the heap is not satisfied with the OutOfMemoryError is thrown. Class information area method (Method Area) for storing a virtual machine has been loaded, a constant, static variables, the JIT compiled code and other data. Java Virtual Machine Specification a method is described as a logic area portion of the stack, but it has an alias called Non-Heap (non-heap). The same method will throw an OutOfMemoryError area. Various literal symbol and part of the region used to store compiled in the process of generating a reference zone, this part of the method into operation time constant pool area is stored after the class is loaded. It should be clear, not only at compile-time constants produced, and will produce new hair in the constant pool constants, such as the intern () method of the String class during operation. Direct memory (Direct Memory) The machine memory is not directly part of the data area of ​​the Java virtual machine is running, but it can significantly improve performance in some scenarios, because it avoids replicate data from the heap and stack in Java Native. Direct memory can also throw an OutOfMemoryError. Area) class information is used to store the virtual machine has been loaded, constants, static variables, the JIT compiled code and other data. Java Virtual Machine Specification a method is described as a logic area portion of the stack, but it has an alias called Non-Heap (non-heap). The same method will throw an OutOfMemoryError area. Various literal symbol and part of the region used to store compiled in the process of generating a reference zone, this part of the method into operation time constant pool area is stored after the class is loaded. It should be clear, not only at compile-time constants produced, and will produce new hair in the constant pool constants, such as the intern () method of the String class during operation. Direct memory (Direct Memory) The machine memory is not directly part of the data area of ​​the Java virtual machine is running, but it can significantly improve performance in some scenarios, because it avoids replicate data from the heap and stack in Java Native. Direct memory can also throw an OutOfMemoryError. Area) class information is used to store the virtual machine has been loaded, constants, static variables, the JIT compiled code and other data. Java Virtual Machine Specification a method is described as a logic area portion of the stack, but it has an alias called Non-Heap (non-heap). The same method will throw an OutOfMemoryError area. Various literal symbol and part of the region used to store compiled in the process of generating a reference zone, this part of the method into operation time constant pool area is stored after the class is loaded. It should be clear, not only at compile-time constants produced, and will produce new hair in the constant pool constants, such as the intern () method of the String class during operation. Direct memory (Direct Memory) The machine memory is not directly part of the data area of ​​the Java virtual machine is running, but it can significantly improve performance in some scenarios, because it avoids replicate data from the heap and stack in Java Native. Direct memory can also throw an OutOfMemoryError.


Guess you like

Origin blog.51cto.com/14360146/2429483