I want to run my Java app and for a given workload be able to see:
I know broadly where the bottle neck is in my application but I need a much more fine grained view in order to narrow it down.
Thanks
Edit jvisualvm looks like the tool - it identified the problem in about 30 seconds. I just need to know what 'selftime' means in the context of a method profile. Thanks
Which of the below is not a Java Profiler? Explanation: Memory leak is like holding a strong reference to an object although it would never be needed anymore. Objects that are reachable but not live are considered memory leaks. Various tools help us to identify memory leaks.
JProfiler is a Java profiler tool and is useful for developers/testers as it can be used to analyze performance bottlenecks, memory leaks, CPU loads, and to resolve threading issues. JProfiler works both as a stand-alone application and as a plug-in for the Eclipse software development environment.
Simplest approach for a program running in java 6 from Sun is to use the jvisualvm program in the jdk. Allows you to attach and profile without any special setup.
Easiest way is to use -prof, e.g: java -prof -jar yourjar.jar
That will print a file called java.prof after the program has finished running.
See the HPROF documentation page
In my application I use: -Xrunhprof:cpu=samples,thread=y,doe=y
This prints a report that contains, amongst other things, this:
CPU SAMPLES BEGIN (total = 55110) Sun Feb 7 17:02:51 2010 rank self accum count trace method 1 69.68% 69.68% 38399 300361 java.net.SocketInputStream.socketRead0 2 24.40% 94.08% 13448 300386 java.net.SocketInputStream.socketRead0 3 0.20% 94.28% 108 300425 java.io.FileOutputStream.writeBytes 4 0.19% 94.47% 107 300976 java.net.PlainDatagramSocketImpl.receive0 5 0.19% 94.65% 102 300414 package.BlockingSampleBuffer.addSample 6 0.16% 94.82% 90 300365 java.net.SocketOutputStream.socketWrite0 7 0.16% 94.98% 89 300412 package.BlockingSampleBuffer.addSample 8 0.15% 95.13% 84 300430 java.lang.Object.wait 9 0.14% 95.27% 77 300592 java.io.FileOutputStream.writeBytes 10 0.14% 95.41% 76 300566 java.lang.AbstractStringBuilder.<init>
So you can see the total time (in seconds) spent in various methods. In mine the app spends most of its time waiting for data from a remote host (not unlikely over an internet connection).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With