JVM Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.10

VM Memory Usages on Windows Systems

This section provides a tutorial example on how to check HotSpot VM memory usages on Windows systems using the Runtime class.

Let's use the following simple program to see the memory usages of the Java HotSpot VM:

class LongWhile {
   public static void main(String[] a) {
      Runtime rt = Runtime.getRuntime();
      System.out.println(" Free memory: " + rt.freeMemory());
      System.out.println("Total memory: " + rt.totalMemory());
      while (true);
   }
}

The following notes were taken in 2007 on a Windows XP system.

This program was compiled with JDK 6u2, and executed in two command windows: one with the Client VM, and the other with the Server VM. They both reported the same amount total memory and free memory in the run time environment, as shown in the table below:

C:\>\progra~1\java\jdk1.6.0_02\bin\java LongWhile
 Free memory: 4997088
Total memory: 5177344

C:\>\progra~1\java\jdk1.6.0_02\bin\java -server LongWhile
 Free memory: 4997088
Total memory: 5177344

So the JVM itself used about 5177344 - 4997088 = 180256 bytes for both client and server versions. Comparing with notes taken on JDK 1.4.0, JDK 6 seems to have smaller footprint 252240 - 180256 = 71984 bytes.

While the two programs were running, I also used the Windows XP Task Manager to look at them from the operating system point of view. The Task Manager reported a 6K less memory usage in the Server VM. See the table bellow for details:

            Task Manager   Run Time Environment
JVM         Memory CPU     Free    Total

Client VM   6996K  50%     4997088 5177344
Server VM   6990K  50%     4997088 5177344

The following notes were taken in 2004 on a Windows 2000 system.

This program was compiled with j2sdk1.4.0_02, and executed in two command windows: one with the Client VM, and the other with the Server VM. They both reported the same amount total memory in the run time environment. But the Server VM gives 248 bytes less free memory.

While the two programs were running, I also used the Windows 2000 Task Manager to look at them from the operating system point of view. The Task Manager reported a 676K more memory usage in the Server VM.

See the table bellow for details:

            Task Manager   Run Time Environment 
JVM         Memory CPU     Free    Total   Used

Client VM   4576K  50%     1779376 2031616 252240
Server VM   5252K  50%     1779128 2031616 252488

Last update: 2007.

Table of Contents

 About This Book

 Download and Install Java SE 1.6 Update 2

 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

 What Is HotSpot?

 Running Java HotSpot Client VM

 Running Java HotSpot Server VM

VM Memory Usages on Windows Systems

 JRockit JVM 7.0 by BEA Systems

 JRockit JVM 8.0 by BEA Systems

 Memory Management Rules and Tests

 Garbage Collection Tests

 Stack Overflow Tests

 Thread Testing Program and Result

 StringBuffer Testing Program and Result

 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

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2010
VM Memory Usages on Windows Systems