Chapter 3. Data Collection

Table of Contents

Invoking your application from the MJP GUI
Caveats
Specifying -Xrunmjp on the command line
Specifying -Xrunmjp in the environment
Opening The Data File
Caveats

This chapter explains how to collect profile data with MJP. The first step to using MJP is collecting data. To collect data, the application you want to profile must be executed with the profiler agent enabled. The profiler agent can be enabled in the following ways:

The first method requires the least knowledge, but is not always the most convenient. Which one you use is up to you. I will detail each of these below.

Warning

There are known problems with JVMPI and the Just-in-Time compiler (JIT). It is highly recommended that the JIT be disabled whenever the JVM is being profiled. Failure to do so will most likely result in memory faults. One way to disable the JIT is to specifiy the command line option -Djava.compiler=NONE. The MJP GUI does this by default, unless the default environment has been changed via the Tools -> Options dialog.

Note

If you have installed MJP using one the tarball methods, ensure that MJP_HOME/bin is in your PATH environment variable before performing any of the steps below. This is used by the JVM to find the MJP profiler agent dynamic library. This is not needed if you installed MJP with the Windows Installer file, because it places the necessary DLLs in the system directory.

Invoking your application from the MJP GUI

  1. Start the MJP GUI. On Windows, this can be done by executing mjp.exe or by double clicking on %MJP_HOME%/lib/mjpgui.jar in Windows Explorer. On Linux, this can be done by executing mjp.

  2. Select File->Run.

  3. Enter the full path to the executable used to invoke your application into the Executable field or click on the ... button and use the file chooser. This may be a JVM (e.g. C:/j2sdk1.4.0/bin/java.exe), a DOS batch script that wraps a JVM, or anything else that eventually invokes a JVM (e.g. mjp.exe). This works because MJP GUI makes use of the environment variables _JAVA_OPTIONS and IBM_JAVA_OPTIONS to invoke the MJP profiler agent. As long as each process passes these environment variables to its child, the profiler agent will be invoked and data collection will take place.

  4. Enter the required command line arguments for your application into the Command Line Arguments field.

  5. Enter the full path of the directory you would like MJP to set the current working directory to before it executes your application or click on the ... button and use the file chooser.

  6. If your application requires environment variables to be set, click on the Environment button and use Edit Environment Variables dialog to specify them.

  7. Click on the Run button.

Caveats

  • There is currently no way to start the profiler agent in suspended or samples mode from the MJP GUI.