The structure of the JVM overview 1

Run-Time Data Areas

The pc Register

JVM can support many thread run at once.
Each JVM thread has it’s own pc register.

At any point,thread executing the code of a single method ,
called the current method for that thread.

If the method is a native method, pc register is undefined,
else the pc register contains the address of JVM instruction current being executed.

It is wide enough to hold a returnAddress or a native pointer on the specific platform.

Java Virtual Machine Stacks

Each Java Virtual Machine thread has a private JVM stack

A JVM stack stores frames, frames may be heap allocated.

  • Requires a larger JVM stack than is permitted
    StackOverflowError in infinite recursion this error happen.

  • Stacks dynamically expanded, and expansion is attempted but
    insufficient memory can be made available to effect the expansion.
    OutOfMemoryError in fames too many? in stack this error may happen.

Heap

The heap is the run-time data area, it’s a ‘public area’.
GC be appointed to manage this area.

OutOfMemoryError when frame need memory size over the maximum heap size.

Method Area

Method Area is a ‘public area’ as well.

It stores

  1. per-class structures such as the run-time constant pool
  2. field and method data
  3. the code for methods and constructors, including
    the special methods (§2.9) used in class and instance initialization
    and interface initialization.

Accturally it is the origin class library of all programes in JVM.

OutOfMemoryError expansion/initialization is attempted
but insufficient memory can be made available

Run-Time Constant Pool

Each run-time constant pool is allocated from the JVM’s method area.

The run-time constant pool serves a function similar to
that of a symbol table for a programming language

OutOfMemoryError expansion/initialization is attempted
but insufficient memory can be made available

Native Method Stacks

JVM may use conventional stacks,
colloquially called C stacks to support native method.

Also be used by the implementation of an interpreter for the JVM’s
instruction set in a language such as C.

If JVM rely on conventional stack, it need not supply native method stacks.

If supplied, native method stacks are
typically allocated per thread when each thread is created.

  • StackOverflowError thread requires a larger native method stack than is permitted
  • OutOfMemoryError expansion/initialization is attempted
    but insufficient memory can be made available