Java multi-threaded - running stack analysis

class file contents

JAVA class file that contains bytecode program executed; compact data format are arranged in strict accordance with the class file binary stream, without any intermediate separator; at the beginning of a file has 0xcafebabe (16 hex) a special flag.

Java multi-threaded - running stack analysis

JVM run-time data area

Java multi-threaded - running stack analysis
Thread Exclusive: Each thread will have its separate space, with the thread lifecycle while creating and destroying
threads share: all threads can access this memory data, with the virtual machine created and destroyed or GC

Methods district

JVM loads a class for storing information, a constant, static variables, the compiled code and other data.
Virtual Machine Specification This is a logical division. Depending on the specific implementation to achieve the virtual machine.
Such as: oracle on the HotSpot permanent passages in the method area java7, java8 space on the metadata, and manages the area by GC mechanism

Heap

Java multi-threaded - running stack analysis
Heap memory can also be broken down into: the old era, the Cenozoic (Eden, From Survivor, To Survivor )
instance created by the JVM startup stored objects. The garbage collector is mainly managed heap memory.
If full, there will be an OutOfMemoryError.

VM stack

VM stack, each thread in this space there is a private space.
A plurality of stack frames from the thread stack (Stack Frame) composition.
A thread may perform one or more methods, a method corresponding to a stack frame.
Stack frame contains: the local variable table, the operand stack, dynamic link, the method returns the address information and other accessories.
The default maximum stack memory is 1M, is thrown beyond StackOverflowError

Native method stacks

And virtual machine stack function is similar to the virtual machine as a virtual machine execution stack is prepared JAVA method, native method stacks are prepared using local Native method for virtual machines.
Virtual machine specification does not provide specific implementation, to be implemented by different virtual machines manufacturers.
HotSpot virtual machine virtual machine stack and implementation of native method stacks of the same. Similarly, after exceeding size can also throw StackOverflowError.

Program Counter

Program counter (Program Counter Register) record the current position of the byte code execution thread, bytecode instructions are stored in the address, executed if the Native method, the counter value is null.
Each thread in this space there is a private space, taking up less memory space.
CPU at the same time, only one thread of instructions executed. JVM will take turns switching and multi-threaded CPU allocation mode execution time. To post a thread switch is required by the program counter, to restore the correct execution position.

Guess you like

Origin blog.51cto.com/flowstone/2432376