views:

420

answers:

10
+3  Q: 

profile java code

I need to profile my JAVA SRC code for some particular problem I am currently working on. I've been using the trial version of a tool called JProfiler.

I'd like to learn of some good community open-source tools, if available; other than that I am also looking forward to learn of some standard techniques that are widely adopted (or must know).

For C Code optimization I use VALGRIND; please also let me know of good tools available on Windows.

+4  A: 

You can take a look at the answers to this question: open source java profilers

akf
+5  A: 

Java 1.6 comes with a rudimentary profiler: jvisualvm. It is in the same directory as java and javac.

SingleShot
The visualvm tool comes only with the JDK (not the JRE) and was added in Jave 6 update 07 - it wasn't present in the original Java 6 release.
Michael Borgwardt
I think VisualVM is only available since update 7 (or was it 10). But other than that it's has a very nice ease-of-use/usefullnes ratio. Also: it's available as a standalone application as well: https://visualvm.dev.java.net/
Joachim Sauer
+3  A: 

Netbeans has a pretty decent Java profiler built in.

TwentyMiles
The NetBeans profile is actually related to jvisualvm (the tool suggested by SingleShot). I'm not sure which one is a derivative of the other, however.
Thomas Owens
The profiling component of visualvm was originally developed as part of netbeans.
Michael Borgwardt
+1  A: 

While not OpenSource, I personally really like YourKit - it has great visualization and is really easy to use.

Chris Boran
+1  A: 

The "jvisualvm" tool in the latest Java 6 JDK contains a profiler (from Netbeans) and can attach to an already running program, making it very simple to do initial investigations.

Thorbjørn Ravn Andersen
+1  A: 

JRockit Mission Control, it's not open source, but it's a commercial profiler you're free to use for development. Here you can read what's new in the latest release.

Kire Haglin
A: 

Supposedly Eclipse TPTP can attach its profiler to Java process but I could never manage to get it work nicely. NetBeans Profiler is by far the easiest to attach to external processes.

Once you have your profiling data or heap dump, my choice of poison is Eclipse Memory Analyzer to do the analysis.

Cem Catikkas
Yeah, TPTP is horribly difficult to set up and use. Also incredibly slow.
Michael Borgwardt
Though I had some issues with the setup, I had success using "Eclipse TPTP" to profile Java code and I found its analysis to be quite useful.
sateesh
A: 

Not all the tools are open source, but you can find a listing of all the available tools at http://javatoolbox.com/categories/profiling-debugging

Each tool is referenced with a short description of what it proposes.

Fabrice
A: 

I liked Jrat a lot for Java profiling: http://jrat.sourceforge.net/

Free open source C memory leak (and other detector) that works in Windows: duma (http://duma.sourceforge.net/). It's not as easy to use as Valgrind (you need to edit your sources and it doesn't have that nifty "do not report this" option - i've not found it yet anyway). The like-Valgrind options for Windows are all commercial (IBM's Purify seems the best but the license is quite pricy)

I do C optimization on windows using the gcc tools, gcov I think is what is used for profiling (might be wrong, haven't used it in a while)

laura
A: 

Try taking "stackshots". It's the no-profiler alternative.

It's not just another pretty face, but it gets results.

Mike Dunlavey