Profiling made easy Logo

  Our latest release is 1.0-beta2
see file list, release notes, and changelog)


Profiler4j is an open-source CPU profiler for Java. To get started, just follow the tutorial or see some screenshots.

Notice that this project is in beta stage and still have some bugs. However, as far as I know, it is fairly stable with typical applications such as Tomcat and JBoss. A final hint: if you develop in JDK1.4 or 1.3, please see this FAQ.

IMPORTANT: please avoid JVMs older than 1.5.0_04 as they have a lot of JVMTI bugs.




Call Graph
Call Tree
Call graph with method details Call tree

Memory Monitor
Class List
Memory monitor Class list with instrumentation status

Edit Threads
Profiling rules being edited Thread monitoring in JBoss


(Step 1) Download and Install

Download the latest release here and unzip it to your disk (c:\ for instance). You can also  checkout the souces from  CVS and build it from scratch. In this case, you'll want to download and install ant.

(Step 2) Prepare and Start Your Target Application

In your target application (the one you want to profile), add the following JVM option, as shown in the command line below (change the path as needed):
java -javaagent:c:\profiler4j-1.0-beta2\agent.jar
You should see something in the console such as
[PROFILER4J:0] +---------------------------------------+
[PROFILER4J:0] | Profiler4j 1.0-beta2 (build 26) |
[PROFILER4J:0] | Copyright 2006 Antonio S. R. Gomes |
[PROFILER4J:0] | See LICENSE-2.0.txt for more details |
[PROFILER4J:0] +---------------------------------------+
[PROFILER4J:0] Listening on port 7890...
[PROFILER4J:0] JVM waiting connection from Profiler4j Console...
You may need to increase the maximum heap as well by using -Xmx128m (default is 64m). You can also pass aditional parameters to the agent: To use these options simply add them after a '=' (no spaces allowed):
java -javaagent:agent.jar=waitconn=false,verbosity=1

(Step 3) Start the Profiler4j Console

Execute the following command to open the remote console:
java -jar c:\profiler4j-1.0-beta2\console.jar
In Windows you may be able to simply double click the jar.

(Step 4) Customize Profiling Rules

Perform any changes to the profiling rules before you connect, such as the host and port. Also, you can use the load/save buttons to manage your settings.

(Step 5) Connect to the remote JVM and Gather Stats

Connect to the target JVM:

Once you connect to the remote JVM the profiled application continues its startup as expected.  From this moment on you can take snapshots  and reset counters as you wish.

Also, if you change profiling setttings you can activate them while the JVM is running. Just press the "Apply" button and wait for it to complete. Depending on the number of classes this operation can take from a few seconds to a few minutes.  Notice that this will force a stats reset.

The main window has a toolbar with the core actions and four tabs:
Further descriptions for the toolbar buttons:
Rule of Thumb: Configure the profiling rules as restrictive as possible before you connect to the remote JVM. This has two effects: first, it decreases the preparation time and, second, it provides a more accurate report on how your application performs. It's interesting to keep in mind, however, that you can change the profiling rules (and apply them) while your application is running.

Known Bugs and Limitations


FAQ1: How can I profile applications developed in JDK 1.3 and 1.4?

The only requirement is: you must be able to take your compiled code and run it in a 1.5 JVM. Your application does not need to be compiled in the same version. You can develop in 1.4 (even 1.3) as usual and switch to 1.5 only during the profiling session. If a 1.5 JVM does not break your code then you'll be ok. In very rare cases this may occur though (see this thread in the forum for some tips).

FAQ2: How to profile applications in JBoss and Tomcat?

See this thread in the forum.


About Me

I have a Master's Degree in Electrical Engineering. Also, I am a PhD candidate and plan to finish all requirements this year at the State University of Campinas (DCA-FEEC-UNICAMP - Brazil). On the business side, I am a senior developer with more than 8 years of experience in Java. And the last but not the least, it's been a lot of fun coding Profiler4j. I learnt a lot from it, and I hope you enjoy it as much as I did.

Last edited at 2006-07-11