tags:

views:

95

answers:

6

I have a fairly complex Java application that is utilizing a lot of CPU, and would like to know if there is any recommendation on a profile tool that I could use to determine the cause of the CPU utilization. My goal is to pinpoint the location in the code where it is using most of the CPU time.

+3  A: 

I've used jProfiler and YourKit on Linux. But you might find the information you're looking for by running the jconsole that comes with recent JDKs. Good information on how to use it: http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html

Paul Tomblin
I'm actually looking into Profiler4j right now.
beyonddc
A: 

This method is low-tech but works best. Here's a short explanation why.

Since you are not running under an IDE, you can use pstack or lsstack to get stack samples. If the app is using lots more time than it should, then most likely the problem is one or a few rogue function calls, which will be clearly visible on most of the stack samples.

Mike Dunlavey
A: 

Netbeans has good built-in profiler. NB runs quite well on Ubuntu 9.10

If your issue cannot be observed in developement, you can attach the profiler to a remote JVM (your production environment). You have to configure the host JVM to accept the JMS/JConsole connections from the profilers. The JMS/JConsole realtime monitoring visualization charts look pretty awesome.

srini.venigalla
A: 

I have used Visual VM in the eclipse IDE. If you are not on an IDE, jhat and jconsole will help. Google jhat for more info

Anu
A: 

If you are comfortable with Eclipse, I'd recommend TPTP.

reprogrammer
A: 

If you use Sun Java 6 then learn to use jvisualvm in the JDK on the machine running the troublesome program.

It will answer most of your questions, can attach effortlessly to an already running program and is gratis.

Thorbjørn Ravn Andersen