Runtime data areas in Java
The JVM allocates many areas of data at runtime that are used at runtime. Some chunks of data are created by the JVM at startup and destroyed during shutdown. Others are created for each thread and destroyed when the thread is destroyed.
The pc Register (PCR)
The Java Virtual Machine can support many threads of execution concurrently. Each thread of the Java virtual machine has its own PC register (programm counter). At any time, each Java Virtual Machine thread is executing the code of one method, namely the current method for that thread. If this method is not native, the pc register contains the address of the Java virtual machine instruction that is currently executing.
In short: there is one PCR for one thread, which is created when the thread starts. The PCR stores the address of the JVM instruction currently executing.
Java Virtual Machine Stacks
Each thread in the JVM has its own stack created at the same time as the thread. The stack in the JVM stores frames. Stacks in the JVM can be fixed in size or dynamically expand and shrink to meet computational requirements.
Heap
The JVM has a heap that is used by all threads of the Java virtual machine. The heap is an area of runtime data from which memory is allocated for all instances and arrays of classes. The heap is created when the virtual machine starts up. Object storage is recovered by an automated data management system (known as a garbage collector); objects are never explicitly deallocated. The JVM does not imply any specific type of automatic storage management system, and the management method can be selected according to the system requirements of the developer. The heap can be of a fixed size, or it can be expanded according to computational requirements, and can be shrunk if a large heap becomes unnecessary. Heap memory should not be contiguous.
Method Area
The JVM has a method area that is common to all threads. It stores structures for each class, such as a constant pool, field and method data, and code for methods and constructors, including special methods used to initialize classes and instances and initialize an interface. Although method scope is logically part of the heap, simple implementations might not be garbage collected. The method area can be of a fixed size, or it can be expanded according to the computational requirements and can be reduced if a large method area becomes unnecessary.
Run-Time Constant Pool
A run-time constant pool exists for each class or interface at runtime and is represented by the constant_pool table in the *.class file. It contains several kinds of constants, from numeric literals known at compile time to method and field references that must be resolved at run time. The run-time constant pool itself performs a function similar to that of a symbol table for a regular programming language, although it contains a wider range of data than a typical symbol table. Each run-time constant pool is separate from the JVM's method area. The JVM creates a run-time constant pool along with the creation of a class or interface.
Native Method Stacks
A Java virtual machine implementation can use common stacks, commonly referred to as "C stacks", to support native methods (methods written in a language other than the Java programming language).
Read also:
Comments
Post a Comment