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

Viewing Shared Memory of JVM Processes

This section provides a tutorial example on how to view shared memory among JVM processes using vadump.exe.

As suggested by Steve Bohne from Sun.COM, if you want to see the shared memory usage of JVM processes, you should install vadump.exe from Microsoft.

vadump.exe is a command line tool that shows very detailed information of a running process on a Windows system. There are 3 options you need to use with vadump.exe to get the private memory and shared memory usages:

  • "-p PID" - Specifies a running process by the process ID, which can be obtained by the tasklist.exe command on a Windows XP system.
  • "-o" - Tells vadump.exe to report a snapshot of the workingset of the specified process.
  • "-s" - Tells vadump.exe to print summary information only.

With vadump.exe and tasklist.exe ready, let's see how much memory will be shared by multiple JVM processes with CDS turned off:

(Open first command window)
C:\>\progra~1\java\jdk1.6.0_02\bin\java -cp . -Xshare:off
   LongSleep
 Free memory: 4997088
Total memory: 5177344

(Open second command window)
C:\>\progra~1\java\jdk1.6.0_02\bin\java -cp . -Xshare:off
   LongSleep
 Free memory: 4997088
Total memory: 5177344

(Open third command window)
C:\>tasklist
Image Name       PID Session Name Session# Mem Usage
============= ====== ============ ======== =========
...
java.exe        2312                     0   6,580 K
java.exe        3920                     0   6,548 K
(tasklist.exe reports the total memory usage 
   in the same way as Windows Task Manager)

C:\>\progra~1\resour~1\vadump -o -s -p 2312
Category                     Total    Private Shareable Shared
                         Pages KBytes  KBytes    KBytes KBytes
...
      Total Modules        794   3176     300         0   2876
      Total Dynamic Data   816   3264    3120         4    140
      Total System          45    180     180         0      0
Grand Total Working Set   1655   6620    3600         4   3016

C:\>\progra~1\resour~1\vadump -o -s -p 3920
Category                     Total    Private Shareable Shared
                         Pages KBytes  KBytes    KBytes KBytes
...
      Total Modules        794   3176     300         0   2876
      Total Dynamic Data   804   3216    3088         4    124
      Total System          49    196     196         0      0
Grand Total Working Set   1647   6588    3584         4   3000

Now we know that:

  • Even without CDS feature turned on, there is about 3 MB of memory shared by all JVM processes. This shared memory is resulted from DLL files used by JVM like: jvm.dll, java.dll, ntdll.dll, kernel32.dll, etc.
  • LongSleep.java application only need about 3.5 MB of private memory to run, which is about half of the total memory reported by Windows Task Manager.

Now let's repeat the same test with CDS turned on:

(Open first command window)
C:\>\progra~1\java\jdk1.6.0_02\bin\java -cp . -Xshare:on
   LongSleep
 Free memory: 4997088
Total memory: 5177344

(Open second command window)
C:\>\progra~1\java\jdk1.6.0_02\bin\java -cp . -Xshare:on
   LongSleep
 Free memory: 4997088
Total memory: 5177344

(Open third command window)
C:\>tasklist
Image Name       PID Session Name Session# Mem Usage
============= ====== ============ ======== =========
...
java.exe        1772                     0   7,032 K
java.exe         420                     0   7,032 K
(tasklist.exe reports the total memory usage 
   in the same way as Windows Task Manager)

C:\>\progra~1\resour~1\vadump -o -s -p 1772
Category                     Total    Private Shareable Shared
                         Pages KBytes  KBytes    KBytes KBytes
...
      Total Modules        784   3136     300         0   2836
      Total Dynamic Data   925   3700    2124         4   1572
      Total System          59    236     236         0      0
Grand Total Working Set   1768   7072    2660         4   4408

C:\>\progra~1\resour~1\vadump -o -s -p 420
Category                     Total    Private Shareable Shared
                         Pages KBytes  KBytes    KBytes KBytes
...
      Total Modules        784   3136     300         0   2836
      Total Dynamic Data   925   3700    2124         4   1572
      Total System          59    236     236         0      0
Grand Total Working Set   1768   7072    2660         4   4408

Comparing with CDS turned off, the results show that:

  • The shared memory has been increased from 3000 KB to 4408 KB. The increased shared memory amount 1408 KB was mainly coming from the Dynamic Data category, which is probably how the CDS shared archive file was used by JVM processes.
  • Of course, turning on the CDS feature costed bout 7072 - 6588 = 484 KB extra memory usage.
  • The net saving on private memory usage is about 1408 - 484 = 924 KB, or 3584 - 2660 = 924 KB.

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

 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)

 What Is Class Data Sharing?

 Regenerating Shared Archive

 Startup Time Saving with Restoring Shared Archive

 Startup Time Saving with Multiple JVM Processes

 Footprint Saving with Restoring Shared Archive

Viewing Shared Memory of JVM Processes

 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
Viewing Shared Memory of JVM Processes