Sun Java Solaris Communities My SDN Account Join SDN
 
FAQ

jvmstat FAQ

 
 
This Frequently Asked Questions list is part of the jvmstat 3.0 tools  » Read More
  1. I downloaded and installed the jvmstat 1.0 tools, but the jvmps command doesn't list any of the running JVMs. If I run the jvmstat and visualgc tools I get an error message
  2. When I try to use the jvmstat 1.0 tools with J2SE 1.4.2, the HotSpot JVM crashes with a diagnostic message
  3. The HotSpot 1.4.2 JVM shipped as part of the J2SE 1.4.2 release. When will the jvmstat tools that are capable of monitoring this version be released?
  4. I'm running on Windows and I've installed J2SE 1.4.2 and jvmstat 2.0, but when I run jvmps it does not display any java processes. I can run 'visualgc 0' and it will work, but I cannot get visualgc or any other jvmstat tool to monitor other Java processes.
  5. Does jvmstat support J2SE 5.0?
  6. What are the new command names?
  7. Where is the explanation for the jstat output fields?
  8. How can I monitor an application which is behind a firewall?
  9. Is there any documentation in the download bundle?
  10. Are there any examples of how to use visual gc?
  11. I understand that JDK 5.0 and jvmstat 3.0 can monitor HotSpot 1.4.1, 1.4.2, and 1.5.0 JVMs, but I really, really, really, (no I mean REALLY!) cannot install JDK 5.0 on my system. Is there any way that I can download the old 1.1 or 2.0 distributions?
  12. I've installed JDK 5.0 and jvmstat 3.0 on my Windows system. I can run jps and jstat without any problems, but when I try to run visualgc I get an error?
  13. I am using a JVM that is not the Sun HotSpot JVM... can I use jvmstat?
  14. I'm running jvmstat on Windows and I can't monitor one of the Java applications?
  15. I'm getting the error "Could not attach to vmid : Could not map vmid to user Name"?
  16. I'm getting a java.lang.NoClassDefFoundError error?
  17. I get an error when trying to monitor a JDK 6 JVM with jvmstat 3.0?
1. I downloaded and installed the jvmstat 1.0 tools, but the jvmps command doesn't list any of the running JVMs. If I run the jvmstat and visualgc tools I get an error message

If the error message is of the form:
    Could not attach to vmid: reason
The jvmstat tools can only monitor the HotSpot 1.4.1 JVM and only when the target JVM has been started with the -XX:+UsePerfData option. Please verify that your application is running with the correct JVM and that the required -XX option is set.


2. When I try to use the jvmstat 1.0 tools with J2SE 1.4.2, the HotSpot JVM crashes with a diagnostic message

If the diagnostic message is of the form:
    # HotSpot Virtual Machine Error, Internal Error
    # Please report this error at
    # http://java.sun.com/cgi-bin/bugreport.cgi
    #
    # Java VM: Java HotSpot(TM) Client VM (1.4.2-b28 mixed mode)
    #
    # Error ID: 504552460E435050011E
    #
The jvmstat 1.0 tools are only compatible with the HotSpot 1.4.1 JVM. Unfortunately, an interface change was required for HotSpot 1.4.2 that prevents the 1.0 tools from monitoring a HotSpot 1.4.2 JVM. The jvmstat 2.0 tools will work with the HotSpot 1.4.2 JVM. However now that the jvmstat 3.0 tools have been released and are compatible with J2SE 5.0, 1.4.2 and 1.4.1 there is no longer a need to use previous versions of jvmstat.

3. The HotSpot 1.4.2 JVM shipped as part of the J2SE 1.4.2 release. When will the jvmstat tools that are capable of monitoring this version be released?

The jvmstat 2.0 tools were designed to work with J2SE 1.4.2, but have now been obsoleted by jvmstat 3.0

4. I'm running on Windows and I've installed J2SE 1.4.2 and jvmstat 2.0, but when I run jvmps it does not display any java processes. I can run 'visualgc 0' and it will work, but I cannot get visualgc or any other jvmstat tool to monitor other Java processes.

The problem is most likely that your default Windows temporary directory is on a FAT type file system. For security reasons, the shared memory exported by the HotSpot JVM is disabled whenever the JVM encounters a FAT type file system (more precisely, any file system that does not support persistent access control lists) as such file systems provide insufficient access controls.

There are two potential work-arounds for this issue:
  1. Set the TMP environment variable to refer to a directory on an NTFS file system, or any file system that supports persistent access control lists. Note that this file system should be local to the machine. Setting this option for target applications is application specific. To set this variable in a command prompt or in a batch script, simply enter the following:

    set TMP=path

    The environment variable can be set globally by adding it to the list of environment variables in the System Properties (Control Panel->System, select the "Advanced" tab and click on the "Environment Variables" button). Through this interface, you can choose to set the variable for all processes run by the current user or globally as a system variable for all processes run by the system.

    The TMP variable must refer to the same location for both the monitored applications and the jvmstat tools.
  2. Changing the TMP environment variable to refer to an NTFS type file system is not always a viable option. For these cases, the HotSpot JVM provides a mechanism to bypass the the file system type check. However, using this mechanism instructs the HotSpot JVM to create the jvmstat shared memory without any access controls, allowing access to the instrumentation exported by the JVM to any user on the system.

    To bypass the file system type check, set the -XX:+PerfBypassFileSystemCheck on the java command line for both the applications you want to monitor and for the jvmstat tools. Setting this option for target applications is application specific. For the jvmstat tools, the following environment variable can be set before running any of the commands:

    set VMARGS=-XX:+PerfBypassFileSystemCheck

    For the jvmstat tools bundled with JDK 5.0, include the following option on the command line (jps command used for illustrative purposes):

    jps -J-XX:+PerfBypassFileSystemCheck

5. Does jvmstat support J2SE 5.0?

Yes, now jvmstat 3.0 can monitor J2SE 5.0, J2SE 1.4.2 and J2SE 1.4.1 virtual machines (effectively replacing and superseding all previous versions of jvmstat).

Note some of the options for (the older) jvmstat command are no longer available with jstat. Also, many of the counters output by the old -name <names> option are no longer available. The preferred interfaces are now the formatted output options jstat -options. If you had scripts that relied on the availability of certain counter names, those script may no longer work as expected.

6. What are the new command names?

If you used previous versions of jvmstat you may be familiar with some of the older names... Here is a mapping of the old names to the new names:
  • JDK 5.0
  • jvmstat 3.0

7. Where is the explanation for the jstat output fields?

Please see the documentation for jstat - Java Virtual Machine Statistics Monitoring Tool

For more background information on garbage collection please see: Tuning Garbage Collection with the 5.0 Java™ Virtual Machine

8. How can I monitor an application which is behind a firewall?

This is really a challenge of using RMI behind a firewall. Please see the RMI FAQ for a discussion of RMI and firewalls (specifically incoming Java RMI calls).

Perhaps the easiest way is with http tunnelling

9. Is there any documentation in the download bundle?

Yes... there is a README file in the directory where jvmstat is installed:
  <jvmstat_install_dir>/README
and there is HTML documentation available at:
  file:///<jvmstat_install_dir>/docs/index.html

10. Are there any examples of how to use visualgc?

Yes. If you attended JavaOne 2004 you received a complementary yearly subscription to JavaOne Online (otherwise anyone may use JavaOne Online for a 30 minute evaluation period).

You can download the PDF for the following JavaOne 2004 Technical Session:
TS-2428 Using jvmstat and visualgc to Solve Memory Management Problems

You may also download the PDF for the JavaOne 2004 Hands-on Lab, LAB-7232 Java™ Technology-Based Application Performance Analysis, by following these steps:
  1. Go to http://java.sun.com/javaone/online
  2. Login with your JavaOne Online username and password
  3. Click on "2004 Labs now available" (in the right navigation bar)
  4. Click on the "View" link for LAB-7232 (you will get a small popup with the HTML documentation)
  5. Download the PDF version of the documentation by clicking on "javaperf.pdf"
Please note: the actual code (the zip file referenced in the documentation) for this hands-on lab is not currently available.

11. I understand that JDK 5.0 and jvmstat 3.0 can monitor HotSpot 1.4.1, 1.4.2, and 1.5.0 JVMs, but I really, really, really, (no I mean REALLY!) cannot install JDK 5.0 on my system. Is there any way that I can download the old 1.1 or 2.0 distributions?

Although we would prefer that users use the jvmstat tools bundled in JDK 5.0, we understand that this is not possible in all case. So, here are the links to the old downloads:

Download click here to download jvmstat 1.1 (209583 bytes, md5sum: 14d4aa8e0df624d10f9b2822200af646 )

Download click here to download jvmstat 2.0 (254284 bytes, md5sum: 0c1f2dd055a6e1888826dbb33111e532 )

However, we can offer little support for these versions.

12. I've installed JDK 5.0 and jvmstat 3.0 on my Windows system. I can run jps and jstat without any problems, but when I try to run visualgc I get an error?

If the error is like this:
     C:\>visualgc -version
     A J2SE 5.0 or later JDK is required to run this tool.
     The java version found in the PATH is:
     java version "1.5.0_01"
     Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
     Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
This is a problem with the visualgc.cmd script. The script attempts to find the location of the JDK by locating the jps.exe binary. However, a JDK that has been installed by the installer places jps.exe in the windows directory. There are two ways to resolve this problem:
  1. set JVMSTAT_JAVA_HOME to point the JDK installation directory. The location of this directory will depend on where you told the installer to install. Assuming that the installer was told to install in c:\java, you can set this variable as follows:
                c:\> set JVMSTAT_JAVA_HOME=c:\java
    
    Make sure that this directory contains the lib\tools.jar file, as that is ultimately what the script is looking for.

  2. Change your path such that the c:\java\bin directory comes before the windows directory c:\winnt\system32. However, this change may affect other applications, so the first option is probably a better choice.
The JVMSTAT_JAVA_HOME environment variable can be set globally by adding it to the list of environment variables in the System Properties (Control Panel->System, select the "Advanced" tab and click on the "Environment Variables" button). Through this interface, you can choose to set the variable globally or for a specific user.

13. I am using a JVM that is not the Sun HotSpot JVM... can I use jvmstat?

We have had a great deal of interest in jvmstat from the Java Licensees, however Sun is the only one to have implemented the jvmstat features in the JVM at this time.

14. I'm running jvmstat on Windows and I can't monitor one of the Java applications?

It is essential that the jvmstat programs have the same credentials as the application they are monitoring. If that is not possible one workaround is to to have jstatd monitor the application (using the same credentials) and allow other users to connect to the local jstatd daemon to run jvmstat programs.

Users have contributed the following techniques for running jstatd as a service:
  • One is based on a utility called "NTWrapper" from http://www.duodata.de/ntwrapper/scrshots.htm
  • Another is an open source tool for running Java applications as a Windows service called 'procrun' http://jakarta.apache.org/commons/daemon/procrun.html
    In order to use procrun it is necessary to know how jstatd can be invoked from Java (ie. public static void main()'s full classname and options). The name of the jstatd main class is sun.tools.jstatd.Jstatd and it's in the tools.jar file in $JAVA_HOME/lib/tools.jar. It will be necessary to remove the "-J" prefix to any arguments that are passed to jstatd.
Now jvmstat tools can monitor applications via jstatd server:
    jps localhost
    jstat -gcutil <vmid>@localhost 1s
Make sure that the jstatd service is started with the same user credentials as the target application.

15. I'm getting the error "Could not attach to vmid : Could not map vmid to user Name"?

This error message occurs when an application makes a native call to setuid() to change the user id associated with the process. Applications often do this because they need to start as root in order to bind to a TCP/IP port below 1024 but then change to a non-privileged user id through this native call. One workaround to this problem is to configure the application to not use a privileged port and to disable its setuid call. Otherwise the jvmstat tools must be run with the same user credentials as the non-privileged application user.

16. I'm getting a java.lang.NoClassDefFoundError error?

If the error is like this:
  H:\>visualgc 1076
  Exception in thread "main" java.lang.NoClassDefFoundError:
  sun/jvmstat/monitor/MonitorException
This may be caused by one of two symptoms: first you may not have JDK 5.0 installed (a JRE or previous version will not work) or secondly there may be whitespace in the path to the JDK.
In the former case please install JDK 5.0. For the latter case there are two workarounds:
  1. Re-install the JDK in a location where there is no whitespace in any path components.
  2. Save the current visualgc.cmd script to visualgc.bak.
    Create a new visualgc.cmd substituting the Windows shortened directory name for the locations of the JDK and jvmstat.
    For example (your actual paths may vary):
    • If the JDK is installed in c:\Program Files\java\jdk1.5.0_2 then use c:\PROGRA~1\java\jdk1.5.0_2 instead.
    • If jvmstat is installed in c:\Program Files\jvmstat then use c:\PROGRA~1\jvmstat instead.
    The resulting visualgc.cmd would then contain the following:
    c:\PROGRA~1\java\jdk1.5.0_2\bin\java -Xbootclasspath/p:c:\PROGRA~1\java\jdk1.5.0_2\lib\tools.jar -jar c:\PROGRA~1\jvmstat\jars\visualgc.jar %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
17. I get an error when trying to monitor a JDK 6 JVM with jvmstat 3.0?

If the error from visualgc is like this:
    Exception in thread "main" java.lang.NullPointerException
        at com.sun.jvmstat.tools.visualgc.MonitoredVmModel.getNativeCompileTime(MonitoredVmModel.java:459)
        at com.sun.jvmstat.tools.visualgc.GCSample.(GCSample.java:185)
        at com.sun.jvmstat.tools.visualgc.VisualGC.main(VisualGC.java:128)
Make sure that you are using visualgc 3.0 b07 or later. To check which version of jvmstat/visualgc you are using, run the following command:
    visualgc -version
The version number is included in the output. For build 04, you would see the following output:
    Version 3.0_b04 10/12/04 - Requires J2SE/Hotspot 1.5.0 or later
For build 07, you'd see this output:
    Version 3.0_b07 12/10/06 - Requires Sun Java SE 5.0 or later with the HotSpot JVM
If you are using b04, please upgrade to b07.