JVM (Java Virtual Machine) Comments (JDK7)

1, Java memory area

Runtime data area:

  • Java Virtual Machine in the implementation of a Java program, defines several types will be used to run the program during the runtime data area, some of which will be created with the virtual machine starts, with the virtual machine exit and destroyed. Others are one correspondence with the thread, which corresponds to the thread of a data area will be created and destroyed with the thread begins and ends.

Program Counter (Program Counter Register):

  • Memory is a small, thread private region OOM (OutOfMemoryError) and does not occur (since it is only the line number indicator bytecode currently executing thread).
  • In the conceptual model of the Java virtual machine (refer merely conceptual model, different types of virtual machines may have a more efficient approach), is a need to select the next instruction when executed by the bytecode interpreter works by changing the value of the counter bytecode instructions, branching, looping, branching, exception handling, and other basic functions thread recovery relies counter complete.
  • Java virtual machine can support multiple threads execute simultaneously (refer to "Java language specification" in Chapter 17), by way of rotation time slice of the processor to execute threads. At any time, a processor (for multi-core processors means that a kernel) can only handle one thread of instructions, in order to ensure a thread switch to return to the correct execution of instructions, Java virtual machine is assigned one for each thread independent program counter, between the threads without disturbing each other, isolated storage.
  • If the method is executing thread is not native (ie Java method ), then the program counter on the preservation of the Java Virtual Machine bytecode instructions being executed address, if this method is native, the value that the program counter is undefined.
  • Capacity should be at least the program counter is used to save a local returnAddress type of data or a pointer associated with the platform.

Stack Java Virtual Machine (Java Virtual Machine Stack):

  • Java virtual machine thread stack is private, its life cycle is consistent with thread.
  • Is a virtual machine stack Java memory model described method performed: Each method creates a stack frame (Stack Frame) while performing table for storing local variables, operand stack, dynamic linking, for export information. Each method until the completion of the execution procedure is called, a corresponding stack frame on the stack from the stack to the virtual machine process stack.
  • Various basic types of local variable table stored in the known compile (boolean, byte, char, short, int, float, long, double), object reference (reference type, it is not equivalent to the object itself) and returnAddress type (pointing address a byte code instruction).
  • Note that the 64-bit long and double types of data that can take two local variable space (Slot), a remaining data type only. Desired local variable table memory during compilation has been completed assignment, when entering a method, this method requires much local variables allocated space in the frame is already confirmed, and the method will not change during operation of local the size of the variable table.
  • Java virtual machine stack may occur following two anomalies: If the request thread stack capacity allocation (stack depth) exceeds the maximum Java virtual machine stack permitted capacity (depth), Java virtual machine will throw a StackOverflowError exception; if Java virtual machine stack dynamic expansion (currently most of the virtual machine supports dynamic expansion), and extension movements have tried, but can not currently apply to enough memory to complete the expansion, or when there is not enough memory to create a new thread to create corresponding virtual machine stack, a Java virtual machine that will throw an OutOfMemoryError exception.

Guess you like

Origin www.cnblogs.com/xihuantingfeng/p/11645220.html