JVM Tutorials - Herong's Tutorial Examples - Version 4.23, by Dr. Herong Yang
What Are Runtime Data Areas?
This section describes 6 JVM runtime data areas: Method Area, Heap, Direct Memory, PC Register, JVM Stack and Native Method Stack.
What Are Runtime Data Areas? Here is the definition the JVM specification: "The Java Virtual Machine defines various run-time data areas that are used during execution of a program. Some of these data areas are created on Java Virtual Machine start-up and are destroyed only when the Java Virtual Machine exits. Other data areas are per thread. Per-thread data areas are created when a thread is created and destroyed when the thread exits."
There are 6 JVM data areas divided into 2 categories:
Here a shot description of each JVM runtime data area:
1. Method Area - A thread shared data area that stores per-class structures such as the run-time constant pool, field and method data, and the code for methods and constructors.
2. Heap - A thread shared data area that stores all data objects including both class instances and arrays, except those allocated explicitly in Method Area and Direct Memory area. Objects in heap are allocated when explicitly requested by the application and deallocated by JVM garbage collector automatically.
3. Direct Memory - A thread shared data area that stores buffer objects allocated explicitly in direct memory area. Objects in direct memory are also automatically deallocated by JVM garbage collector.
4. PC (Program Counter) Register - A per-thread data area that contains the address of the instruction currently being executed in the thread. If the method currently being executed is native, the value of the PC register is undefined.
5. JVM Stack - A per-thread data area that stores a stack of frames. Each frame holds local variables and partial results, and plays a part in method invocation and return of the current running method.
6. Native Method Stack - A per-thread data area that stores similar data elements as a JVM stack to execute native (non-Java) methods.
The picture below shows how all 6 JVM runtime data areas are related to each other:
Last update: 2014.
Table of Contents
Downloading and Installing JDK 1.8.0 on Windows
Downloading and Installing JDK 1.7.0 on Windows
java.lang.Runtime Class - The JVM Instance
java.lang.System Class - The Operating System
ClassLoader Class - Class Loaders
Class Class - Class Reflections
JRockit JVM 28.2.7 by Oracle Corporation
Method Area Expansion Demonstration
OutOfMemoryError on the Method Area
Method Area Growth with Dynamically Generated Classes
Garbage Collection Issue with Dynamically Generated Classes
Interned Strings Stored in Heap
Direct Memory Expansion Demonstration
allocateMemory() Method on Direct Memory
JVM Stack Expansion Demonstration
PC Register and Native Method Stack
Memory Management and Garbage Collectors
JVM Stack, Frame and Stack Overflow
Thread Testing Program and Result
CPU Impact of Multi-Thread Applications
I/O Impact of Multi-Thread Applications
Micro Benchmark Runner and JVM Options
Micro Benchmark Tests on "int" Operations
Micro Benchmark Tests on "long" Operations
Micro Benchmark Tests in JIT Compilation Mode