JVM Tutorials - Herong's Tutorial Examples - Version 4.23, by Dr. Herong Yang
Default Stack Sizes of HotSpot and JRockit
This section provides a tutorial example on how to compare the default behavior of HotSpot and JRockit JVMs. JRockit JVM support a much larger number of nested calls than HotSpot with default settings.
In previous tutorials, we focused on the latest version of HotSpot. Now let's compare the default behavior of different versions of HotSpot and JRockit with this simple StackOverflowTest.java program:
/* StackOverflowTest.java * Copyright (c) 2014, HerongYang.com, All Rights Reserved. */ class StackOverflowTest { static long n; public static void main(String[] a) { n = 0; try { sub(); } catch (StackOverflowError e) { e.printStackTrace(); System.out.println("Maximum nested calls: "+n); } } private static void sub() { n++; sub(); } }
Compile and run StackOverflowTest.java with different versions of JVMs, you will get something like this:
C:\herong>\progra~1\Java\jdk1.8.0\bin\javac StackOverflowTest.java C:\>\progra~1\Java\jdk1.8.0\bin\java StackOverflowTest 2> err.txt Maximum nested calls: 8906 C:\>\progra~1\Java\jdk1.7.0_45\bin\javac StackOverflowTest.java C:\>\progra~1\Java\jdk1.7.0_45\bin\java StackOverflowTest 2> err.txt Maximum nested calls: 8010 C:\>\progra~1\Java\jdk1.6.0_45\bin\javac StackOverflowTest.java C:\>\progra~1\Java\jdk1.6.0_45\bin\java StackOverflowTest 2> err.txt Maximum nested calls: 9349 C:\>\progra~1\java\jrockit-jdk1.6.0_45-R28.2.7-4.1.0\bin\javac StackOverflowTest.java C:\>\progra~1\java\jrockit-jdk1.6.0_45-R28.2.7-4.1.0\bin\java StackOverflowTest 2> err.txt Maximum nested calls: 31156
The result shows that JRockit R28 support a much higher number of nested calls than HotSpot 1.8 with default settings. There are 2 possibilities: JRockit has a larger default stack size or JRockit uses smaller frames. We will find it out in the next tutorial.
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
Memory Management and Garbage Collectors
►JVM Stack, Frame and Stack Overflow
StackOverflowError Exception Test
-Xss JVM Option for Stack Size
Frame Impact of Extra Statements
JVM Stack Expansion and Footprint
JVM Stack Expansion and OutOfMemoryError
Largest Stack Size for HotSpot on Windows
►Default Stack Sizes of HotSpot and JRockit
JRockit Frame Size Smaller than HotSpot
JRockit Expanding Stacks in Bigger Chunks
JRockit Running Out Of Memory Quicker
Largest Stack Size for JRockit on Windows
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