JVM Tutorials - Herong's Tutorial Examples - v5.13, by Herong Yang
Footprint Comparison - OpenJ9 vs. HotSpot
This section provides a tutorial example on how to compare footprint of OpenJ9 and HotSpot JVMs. My tests show that OpenJ9 footprint is 28% smaller than HotSpot on a CentOS Linux computer.
OpenJ9 document claims that OpenJ9 JVM footprint (measured as RSS, Resident Set Size) is 66% smaller than HotSpot after startup. Here is what I did to verify this on my CentOS computer.
1. Verify OpenJDK/HotSpot installation:
herong$ java -version openjdk version "11.0.6" 2020-01-14 LTS OpenJDK Runtime Environment 18.9 (build 11.0.6+10-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.6+10-LTS, mixed mode, sharing)
2. Verify OpenJDK/OpenJ9 installation:
herong$ ./jdk-14.0.1+7-jre/bin/java -version openjdk version "14.0.1" 2020-04-14 OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7) Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.20.0, JRE 14 Linux ... OpenJ9 - 05fa2d361 OMR - d4365f371 JCL - 5757187cae based on jdk-14.0.1+7)
3. Use a simple Java program, LongWhile.java, to test footprint.
/* LongWhile.java * Copyright (c) HerongYang.com, All Rights Reserved. */ class LongWhile { public static void main(String[] a) { Runtime rt = Runtime.getRuntime(); System.out.println("Total memory: " + rt.totalMemory()); System.out.println(" Free memory: " + rt.freeMemory()); System.out.println(" Used memory: " + (rt.totalMemory()-rt.freeMemory())); while (true); } }
4. Run LongWhile.java with OpenJDK/HotSpot, and measure RSS (Resident Set Size) of the JVM process in two terminal windows:
herong$ java LongWhile.java Total memory: 127926272 Free memory: 120359424 Used memory: 7566848 (on another window) herong$ ps -ef | grep java 15799 15182 98 02:27 pts/0 ... java LongWhile.java [herong$ ps -orss --pid 15799 RSS 88556 [herong$ kill 15799
5. Run LongWhile.java with OpenJDK/OpenJ9, and measure RSS (Resident Set Size) of the JVM process in two terminal windows:
herong$ ./jdk-14.0.1+7-jre/bin/java LongWhile.java Total memory: 8912896 Free memory: 2692152 Used memory: 6220864 (on another window) [herong$ ps -ef | grep java 15560 15182 99 04:18 pts/0 ... ./jdk-14.0.1+7-jre/bin/java LongWhile.java [herong$ ps -orss --pid 15560 RSS 63728 [herong$ kill 15560
6. Compare test results:
Used RSS Memory Size ------- ----- HotSpot 7566848 88556 OpenJ9 6220864 63728 % Smaller 18% 28%
Too bad. My test shows only 28%, not 66%, saving of RSS (Resident Set Size) when using OpenJDK/OpenJ9 instead of OpenJDK/HotSpot.
Table of Contents
JVM (Java Virtual Machine) Specification
Java HotSpot VM - JVM by Oracle/Sun
java.lang.Runtime Class - The JVM Instance
java.lang.System Class - The Operating System
ClassLoader Class - Class Loaders
Class Class - Class Reflections
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
Micro Benchmark Tests on "float" and "double" Operations
Install OpenJ9 JVM with OpenJDK on CentOS Systems
►Footprint Comparison - OpenJ9 vs. HotSpot
Startup Time Comparison - OpenJ9 vs. HotSpot