Saturday, June 5, 2010

How to use and install Yourkit, Java Profiler with YourKit

Java Profiling:

In software engineering, program profiling, software profiling or simply profiling, a form of dynamic program analysis, is the investigation of a program's behavior using information gathered as the program executes. The usual purpose of this analysis is to determine which sections of a program to optimize - to increase its overall speed, decrease its memory requirement or sometimes both.

There are many profiler are available in the market for Java. But I use yourkit java profile and going to step by step setup.

How you can profile your java application using yourkit Java profiler.

1. Download yourkit java profiler from here. You can download trial version for 2 weeks and see the website for more information.
2. During installation it will ask path to insatll the yourkit. Give any path but without space like c:\yourkit
3. Create one small project in Eclipse say(JavaTest)
4. Create one simple Java file to check in profiler say (
package com.binod.suman;

* Author @ Binod Suman

public class App
public static void main( String[] args )
System.out.println( "Hello World!" );
App test = new App();

public void check(){
String name="Binod";

public String getName(String s){
System.out.println("YES :: "+s);
for(int i=0;i<10000;i++){
try { Thread.sleep(1000); }
catch (InterruptedException e) { e.printStackTrace(); }
} return s;

5. First start the yourkit. (Start -> All Programs -> Yourkit java profiler -> Yourkit java profiler .
The profiler can automatically detect all locally running profiled applications. If more than one is found, you will be asked to select one. If only one application is found, the profiler will connect to it without prompting you.

6. Now run your now see the YourKit Profiler

It will show one Application runnig (com.binod.suman.App) started without profiler. If you will double click on the application,

YourKit will show one error message that The application cannot be profiled because it has not been started with the profiler.

So, now how you will connect your application with YourKit profiler

1. In Eclispe, right click on the mail java file ( -> Run As -> Run Configurations ... -> Go to Second Tab Argumetns -> Go to VM arguments: and paste
click on Apply then Run.

Next time onward no need to do all these thing, just run it.

Now come to Yourkit profiler this time it will show Started with profiler
Now you can double click on your application (App) and it will show all the CPU, Thread, Memory, Deadloccks, Garbage Collection, Summary details of the your application.


Thanks .......... :)