开发者

Java Profiling on Linux

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 det开发者_如何转开发ermine 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.


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


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.


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


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜