JRockit Expanding Stacks in Bigger Chunks

This section provides a tutorial example on how to compare the impact of footprint of expanding stack size between HotSpot and JRockit. JRockit stack expands in bigger chunks and has a larger footprint.

To look at the impact of stack size on JRockit JVM footprint, we can use the same sample program, MultiStackThread.java, we used for HotSpot JVM.

/* MultiStackThread.java
 * Copyright (c) 2014, HerongYang.com, All Rights Reserved.
class MultiStackThread extends Thread {
   public int maxCount;
   private int curCount;
   public static void main(String[] arg) {
      MultiStackThread t;
      int m = 4;
      int f = 1000;
      if (arg.length>0) m = Integer.parseInt(arg[0]);
      if (arg.length>1) f = Integer.parseInt(arg[1]);
      for (int n=0; n<m; n++) {
         t = new MultiStackThread();
         t.maxCount = f;
      System.out.println("Number of threads started: "+m);
      Runtime rt = Runtime.getRuntime();
      long dt0 = System.currentTimeMillis()/1000;
      while (true) {
         try {
            long tm = rt.totalMemory();
            long fm = rt.freeMemory();
            long dt = System.currentTimeMillis()/1000 - dt0;
            System.out.println("Time, heap total, free and used: "
               +dt+", "+tm+", "+fm+", "+(tm-fm));
         } catch (InterruptedException e) {
   public void run() {
      curCount = 0;
      try {Thread.sleep(1000*60*60);} 
      catch (InterruptedException e) {}
   private void sub() {
      try {      
         if (curCount<maxCount) sub();
         else System.out.println("Count limit "+curCount
            +" reached for thread: "+this.getId());
      } catch (StackOverflowError e) {
         System.out.println("Stack overflow at "+curCount
            +" for thread: "+this.getId());

Compile and run the program with JRockit R28 with 1 thread, different frames and a large stack size (-Xss1m). And measure the JVM footprint using tasklist command in another command window.

Here is the result from my Windows system listed together with results from HotSpot:

         HotSpot 1.8  JRockit R28
Frames    Mem Usage    Mem Usage    (-Xss1m and 1 thread)
     0     14,020 K      4,588 K
    10     14,128 K     20,072 K
   100     14,056 K     20,136 K
  1000     14,100 K     20,340 K
  5000     14,288 K     20,336 K
 10000     14,528 K     20,380 K
 15000     14,784 K     20,548 K
 16000     15,008 K     20,372 K
 17000     15,068 K     20,696 K
 18000     15,028 K     20,484 K
 18429     15,032 K (Stack overflow)
 20000                  20,528 K
 40000                  20,940 K
 80000                  21,624 K
 86596                  23,048 K  (Stack overflow)


Last update: 2014.

Table of Contents

 About This Book

 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

 Sun's JVM - Java HotSpot VM

 JRockit JVM 28.2.7 by Oracle Corporation

 JVM Runtime Data Areas

 Memory Management and Garbage Collectors

 Garbage Collection Tests

JVM Stack, Frame and Stack Overflow

 What Is JVM Stack?

 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

 CDS (Class Data Sharing)

 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

 Outdated Tutorials


 PDF Printing Version