In some environments, it is impossible to
start the Java code from OptimizeIt's user interface or from the command
line because another native program starts the Java virtual machine. Assuming
that the program starting the virtual machine allows you to change basic
Java options, classpath and library path, it is possible to profile your
Java code with OptimizeIt. Profiling in this case is done by:
-
Changing the VM startup parameters to include some extra parameters.
-
Modifying the tested Java program to start OptimizeIt's profiler during
initialization.
-
Starting the tested Java program in its environment.
-
Starting OptimizeIt.
-
Attaching to the tested program.
In this document, <OptItDir>
is the directory where OptimizeIt has been installed. (ex; c:\Program Files\Intuitive
Systems\OptimizeIt302D)
1) Requirements
-
Java code should be executed with Sun's virtual machine. Most virtual machines
derived from Sun's virtual machine work as well. The VM version should
be 1.1.x 1.2 or 1.2.1.
-
The program starting the virtual machine should provide a way to set basic
Java parameters.
-
The tested program source code is required because it is necessary to modify
the initialization phase to start OptimizeIt's profiler.
2) Virtual machine startup parameters
In order to start profiling with OptimizeIt, the following parameters should
be set:
-
CLASSPATH should include <OptItDir>\lib\optit.jar
-
PATH should include <OptItDir>\lib
-
OptimizeIt directory should be defined: -DOPTITDIR=<OptItDir>
-
Class garbage collection should be disabled: -noclassgc
with JDK 1.1 and -Xnoclassgc
with JDK 1.2
-
JIT should be disabled: -Djava.compiler=NONE
-
With JDK 1.2, it is also necessary to start the JVMPI agent: -Xrunoii
3) Starting OptimizeIt's profiler from Java code
Starting OptimizeIt profiler can easily be done by using OptimizeIt's API.
OptimizeIt's API is documented in OptimizeIt user manual, chapter 9. The
following code demonstrates how to start the profiler from any Java code.
import intuitive.audit.Audit;
...
static boolean isProfilerStarted = false;
if(!isProfilerStarted) {
/* Start OptimizeIt's profiler */
Audit.start(1470, Audit.PROFILERS_ALWAYS_ENABLED);
isProfilerStarted = true;
}
...
Note: you will need to add <OptItDir>\lib\optit.jar to compile this
code.
4) Profiling session
-
Start your application and make sure the code starting the profiler is
invoked.
-
Start OptimizeIt from the Start menu.
-
Close the Edit Settings panel by pressing the OK button.
-
From the Program menu, select Attach.
-
Change the port number and the hostname if necessary.
-
Press the Attach button.
Note: OptimizeIt does not have a "detach" function. If you press the stop
button in OptimizeIt, the virtual machine running the tested application
will exit.
Copyright (c) 1997, 1998, 1999 Intuitive Systems Inc.
All rights reserved. Specifications subject to change without notice.
OptimizeIt is a trademark of Intuitive Systems, Inc.
Java and all Java-based trademarks and logos are trademarks
or registered trademarks of Sun Microsystems, Inc. All other brand names
and products are trademarks or registered trademarks of their respective
holders.