Java Profiling Tool for CPU consumption - java

I have used JProfiler, JProbe, AppSight, YourKit for the finding out what code is consuming CPU.
But YourKit looks better than others.
Is there anything better ?

There is jvisualvm in the Sun 6 JDK. It is "better" because it is gratis and easy to use, pretty simple but has the killer feature of being able to attach to a program which is already running. It is a stand alone version of the NetBeans profiler which is also gratis.
If "better" includes price, these are hard to beat.

You cannot ask which is better unless you define what you mean by "better". Basically it's horses for courses. Everyone has their own preferences as to which is the best tool and for what reasons.
There are the main tools I've seen, but it's up to you which you prefer.

Related

Steps involved in profiling java applications

Please explain about the steps involved in profiling a JAVA application? This is irrespective of what ever profiling tools that is used. What are the best practices and steps involved in profiling the java applications?
Experts, any links or documents are really appreciated.
Thanks.
Thanks. The thing I want to know is there are so many profilers available but when we profile a Java applications for OutOfMemory or Memoryleaks , etc . What are the steps we need to go through in profiling the application. Let say I am using VisualVM which does have a profiler , I am getting an OutOfMemory Error in my application my application so huge that I don't know where exactly is the problem even the logger is of no use (just for assumption). In such case how we can figure out where exactly is the problem by using the profiler tool like VisualVM? And what are the steps we need to look into ? Whether we can directly use the CPU and Memory profiling or still we need to go and get the thread dump and analyse it , then create a Heap dump analyze it and then go for a CPU and Memory profiling? I am little confused here. Hence please point me to the right direction as well as the steps involved in profiling a JAVA application to find the memory leaks. Hope I am clear with my question.
Depending on why you need to profile your application you have to decide what filters you will need, as mentioned inthe comments the question is very general, you should provide some more percise information to get some help hier.
Try the following link (in Eclipse):
An introduction to profiling Java applications
And check this List or Open source java profilers
i have used JProfiler and yourkit but i am not satisfied with output for actual performance tuning. currently we have been switched to java melody. This not only help performance optimization in dev but also in production system. Java melody is very easy to integrate and configure and in production you can enable or disable by just updating web.xml
This series of articles should give you a good idea on how you go about serious performance investigation of a relatively complex Java application.
http://www.jinspired.com/solutions/case-studies/scala-compiler

Best way to measure Memory Usage of a Java Program?

I'm currently using VisualVM, but the problem I'm having is that I can't save the graphs it generates. I need to report some data about its memory usage and running time, though running time is easy to get with System.nanoTime(). I've also tried the NetBeans profiler but it isn't what I want, since I'm not looking for specific parts that would be slowing it down or anything, so that would be overkill. The biggest problem with it is that it eats up too much processing time. Also doesn't let me capture/transfer the data easily, like VisualVM, at least as far as I can tell.
Ideally the best way to go about it would be some method call because then I'd be able to get the information a lot more easily, but anything like VisualVM that actually lets me save the graph is fine. Performance with VisualVM is pretty good too, compared to the NetBeans profiler, though I suppose that's because I wasn't using its profiler.
I'm currently using Ubuntu, but Windows 7 is fine. I'd rather have a program that specializes in doing this though, since the information gotten by programs who don't is likely to include the JVM and other things that would be better left out.
Well, apparently, you can save snapshots of the current session and maximize the window in VisualVM, so you could make the charts bigger, take a snapshot and cut them... But that's kind of a hack. Better suggestions welcome.
Runtime.getRuntime().freeMemory();
Runtime.getRuntime().totalMemory();
Look at the Runtime class. It has freeMemory, maxMemory, and totalMemory. That's probably close enough for your purposes.
You may prefer graceful method to measure memory, rather than hack image.
JConsole is known to Monitor Applications by JMX,it provides program API. I guess it is what you need.
See: Using JConsole to Monitor Applications
Try JProfiler. Although its not free you can try evaluation version first.
The HPjmeter console is free. Run your Java process with -Xloggc:<file> and open the <file> with it. Not only can you save your sessions, but you can compare runs. Other options to consider including in your command line are:
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails

(Why) does Tomcat/Java perform better on Linux than on Windows?

I just read this (one) study in which Tomcat under Linux outperformed Windows.
From your experience, is this generally true? Any deep reason that could explain the performance difference?
I don't thing such benchmarks can be so informative, then this one is 4 years old.
By the way these differences usually reside in certain choices related to how the operating system manages memory, cache and threads..
I take any benchmark with a grain of salt. It's possible to game any comparison.
I find that one key is to try and spot any bias that the person doing the comparison might have. There was an infamous comparison of the Java EE Pet Store done with .NET several years back. The group doing the study had been paid by Microsoft. They didn't do all they could to optimize the Java EE solution, putting it in a bad light. The results were discredited as a result.
Does WebPerformance.com have any Linux bias?
If not, there are a lot of factors that enter into such a result. I'd compare all of them carefully, and try to see if I could spot anything important that might have been left out.
Few points (mostly speculation):
Tomcat developed by FOSS on FOSS software, so it is reasonable that it would perform better on FOSS software.
Linux is better operating system ;-)
Generally. It depends on fine tuning experience... If you know windows well you'll tune it better for windows and if you know Linux better then...

I need to use profiler in my IDE

I am using RSA7 as IDE, I need to use profiler in my IDE for memory analysis.
Can any one suggest me
From where I can free download it?
How can I use it with RSA7?
Many Thanks
You don't absolutely need it to be integrated in your IDE, JProfiler is a great one and runs outside the IDE. Although it can run in most IDE's, that you should check on their site JProfiler
Remark: It's not Free, but a profiler pays for it selfs, once you sum up the time it saved you then you understand that it is well spend money!
VisualVM comes with the JDK and includes a pretty good memory profiler. Also not integrated with RSA, but doesn't really need to be.

What advantages have a commercial Java profiler over the free ones, e.g. the one in Netbeans?

Occasionally I have to do some profiling work on Java code, and I would like to know why I should have my boss investigate in a commercial profiler as opposed to just use the one in Netbeans or JConsole?
What would the killer features be that would warrant the investment?
In my experience with JProfiler, it's just an all-round slicker experience than the NetBeans profiler. It's easier to get started, easier to interpret the information and, although I haven't measured it, it seems that JProfiler has less of a negative impact on the performance of the application being profiled.
Also, JProfiler integrates nicely with IntelliJ IDEA. I have to use NetBeans to use the NetBeans profiler, which is an inconvenience because I have to manually configure a free-form project to match the layout of my project.
The NetBeans profiler is usable. Unlike IntelliJ, I wouldn't buy a JProfiler licence for my personal projects because, unlike an IDE, it's not a tool you use all day every day. However, for paid work there's no reason not to buy a better tool. It's not expensive compared to the cost of a developer's time.
I have experience using both NetBeans profiler and JProbe. For performance profiling I have found Netbeans quite useful but where JProbe is superior is for memory profiling.
JProbe has superior tools for comparing heap snapshots and finding the root cause of a memory leak. For example, in JProbe you can view heap shapshots visually as a graph, select nodes to investigate and then delete references to see if the instance could then be garbage collected.
If you are using Netbeans already then starting up the profiler is easy (unless you are using a Maven based project... sigh).
I have used paid profilers as well as the Netbeans one. Netbeans does the job well enough (it was a bit rough when it first came out... but much better now).
The code I profile isn't HUGE so I cannot say if the time spent in profiling is a major factor.
The answer is highly subjective and totally depends on your needs. Things to look at:
1) ease of use in your environment (in the case of NetBeans it is likely that the built in profiler is easiest.
2) time spent starting the prfiler to it actually getting you usable results
3) is it a sampling or tracing profiler? (An overview is here: http://docs.hp.com/en/5992-0757/ch05s01.html
4) can you view the results live or do you have to wait for the profiling to finish?
Here is a link to a slashdot discussion on Java profilers: http://ask.slashdot.org/article.pl?sid=06/06/30/0053237
I've not used Netbeans profiler, but tried JProfiler, Yourkit and JProbe. I found Yourkit slightly better (mainly bought by the usability aspect). Some of the useful features in it are: (you can check if it is available in Netbeans)
J2EE Profiling (Eg. It shows how much time an SQL query took).
Snapshot comparison and annotation
Deadlock detector
Exception telemetry
You can check for more details at their site.
I would say that, ready to use and more performance statistics. I was assigned a profiling job last year when I was interning at a multinational. I used the InfraRED profiler which uses Java aspect oriented API (works with both Aspectwerkz and AspectJ). But I had to extend the profiler to get what my manager wanted. Also, the performance statistics given by the profiler was limited.
But before selecting the profiler I researched a few other opensource profilers. Some of them were trivial and didnt suit what we wanted.
I would also add that, some of them just doesnt work. For example, if we want to collect performance statistics of a web application, all the profilers doesnt support those statistics required for us.
With a completely independent profiler, it's much easier to integrate it with other applications in your toolchain. For example, say you want to run the profiler as part of your build process (say, once a night). Something like JProfiler easily integrates with ANT, whereas profilers built into IDEs may or may not. If you have a separate build machine, installing a local copy of a profiler makes sense, but installing a whole IDE just to get access to one component does not.
If you are using Tomcat you might consider lambdaprobe
http://www.lambdaprobe.org/
(It is for free)
From my experience, YourKit profiler is most usable one. Small usability things really make the difference, but also it is most comprehensive one, containing:
most comprehensive and usable memory snapshots (working also with 1GB+ heaps), with detail object view and primitive data, for every single object. (for example in hashmap you can see if objects are evenly distributed or most are stored in same bucket!) This detail of memory snapshots and its ease of use is my main reason for yourkit.
very little overhead (far less then many other profilers I used)
comparing snapshots
J2EE profiling
deadlock detector, lock status (I think it still misses java.concurrent.locks, bud for synchronized it is great)
Among other things, it's also constantly improving, so who knows what is future holding :)
Compare the features and see if you really need the features provided by commercial software over the free one. If yes then its worth investing.

Categories

Resources