JProfiler is an award-winning all-in-one Java profiler. It's intuitive GUI helps you find performance bottlenecks, pin down memory leaks and resolve threading issues.
Even though JProfiler has a powerful feature set, it's a Java profiler that is extremely easy to use! JProfiler's user interface provides a unified view on the profiled application and puts all the information you need right at your fingertips with its intuitive hierarchy of views.
Configure your application for profiling
When starting up JProfiler, the start center is brought up. Here you can manage and start your profiling sessions. To configure your application for profiling, change to the "New session" tab and click on the New session button. Enter the required information into the session config dialog as described below and select Ok to start profiling. That's all it takes. Note the Help button which appears on all of JProfiler's dialogs displays a context sensitive explanation of all features.
While the configuration dialog displays numerous options that you will not want to miss after becoming familiar with JProfiler, entering the basic pieces of information is really very simple:
1. Enter a name for your session.
2. Enter the name of your main class.
3. Enter your class path.
4. Press Ok.
Before profiling is actually started, the profiling settings dialog is displayed where you can select the focus for your profiling run. Although profiling produces an overhead when running your application, you can minimize it by choosing a setting for which JProfiler only records information that is interesting for you.
If you want to fine-tune your profiling settings, the [Edit] button brings up a dialog with all available configuration options for profiling.
Observe classes and allocations
To find out what is going on the heap in terms of objects and classes, turn to the classes monitor. It gives you continuous updates and lets you set marks to observe changes over time. To see references, allocations and object data for your selection, you can take a snapshot by clicking on the camera in JProfiler's toolbar.
If you want to know where your objects are allocated, you can go to the allocation monitor. Here, you can inspect the call tree and find out what method calls have caused the allocation of a selected class or package. Just like in the allocation monitor, you can display this data for live and garbage collected objects.
An cumulated overview on which methods are responsible for allocations is given by the allocation hot spots view. Each hot spot can be expanded and the backtraces that lead to the invocation of the hot spot are displayed. You can also mark the current values and view the differences in allocations over time.
Find memory leaks
JProfiler's heap walker works like a browser: it displays a current set of objects that can be changed by adding selection steps with the [Use selected] button. You can inspect the current object set in the four views of the heap walker.
In the classes view, you can select one or several classes and add a selection step. The new object set will contain only the selected instances. This is often the first thing you want to do after taking a snapshot. You can perform this step automatically by invoking the heap walker from the classes monitor.
The allocations view of the heap walker shows the allocation tree and the allocation hot spot list of the current object set. You can add a selection step for one or multiple allocation spots or hot spots. The new object set will then be restricted to the selected instances only.
When you're looking for the cause of a memory leak, the reference view is the most important view in JProfiler. Here, you can find out why an object has not been garbage collected. Use the "Show path to GC root" function to show where the JVM hangs on to the selected instance.
Not only is the heap walker your first stop for finding memory leaks, it also makes for an excellent debugging facility. In the data view, you can inspect instances, arrays and classes in the current object set and navigate along references. There are many situations where the usual debugging approach will fail and JProfiler will help you find out.
Zoom in on performance bottlenecks
Controlling your application's performance may be driven by quality of service constraints or by general quality assurance, JProfiler's CPU views lend themselves naturally to both approaches.
To record CPU data, you switch to the CPU section and click on the recording button in JProfiler's tool bar. The first view in the CPU section shows the invocation tree, cumulated for all threads. To find performance related problem spots, just follow the big percentages when opening the tree nodes. Also, the absolute times and the number of invocations that are displayed for each node can help you in getting a feeling for the situation. Once you become familiar with JProfiler, you may want to customize this view to best fit your personal preferences.
The invocation tree is a top-down view on the method calls of your application. This viewpoint is most useful when you experience an actual performance bottleneck in your application. If you want to improve overall performance, a bottom-up view may be more applicable.
This kind of view - called hot spots view - shows the methods where most of the time is spent. By opening these nodes you get backtraces which show the various invocation paths together with the percentages of their contributions. Note that by default, method calls within Java core classes are not shown separately - each of your library calls is treated as opaque. You can change this behavior by deactivating the corresponding filter sets.
The method graph combines both viewpoints. Incoming and outgoing method calls are presented in the same way. For a number of situations, the method graph can give you more insight than the invocation tree and the hot spots view. The best strategy is to use the invocation and hot spots views first and switch to the method graph for detailed analysis.
Solve thread-related problems
Threads can be exceptionally difficult to debug, especially if you don't have sufficient information on the actual sequence and status of the threads in your application. JProfiler's thread views provide you with exactly this knowledge.
The thread history view shows a continuous update of the lifelines of all threads on the horizontal axis. The names of the threads are displayed on the vertical axis in the order of their creation. Each color signifies a different thread status. Orange means that the thread was sleeping, green stands for a runnable thread while red is displayed if the thread was waiting for a monitor. You can zoom in and out to your desired detail level or have the time axis fit your window's size automatically.
If you're more interested in what's happening right now, the thread monitor view is the right place to look at. Here, you can sort threads, filter with respect to thread status and view additional information on each thread.
Should you ever have a deadlock in your application, the deadlock detection graph will help you analyze the involved threads and the locking situation. Simple deadlocks like the one shown could be worked out by hand from the other views, but for complicated deadlock involving a greater number of threads this view is indispensable.
Reducing general monitor contention and debugging locking sequences requires a detailed view of the current monitor usage and a history of all monitor-related events. JProfiler has both. Below you see the monitor usage history which shows a blocking event together with the stack trace of the waiting thread.
Keep an eye on your JVM
Monitoring cumulative parameters of the virtual machine can be a highly fruitful activity, even if everything seems to be all right. Measuring and observing parameters like heap size, object count, loaded classes and thread numbers can point to dangerous trends and problematic behavior to look out for. In its VM telemetry view section, JProfiler features various telemetry controls which provide you with the information you need to stay one step ahead.
The number of objects on the heap, split in arrays and non-arrays. This is your first stop if you are suspecting a memory leak. All objects with live references are included, as well as those which are unreferenced but the garbage collector hasn't had a chance to collect yet.
The garbage collector activity which displays freed and moved objects. If your application is thrashing the heap excessively, this will show up here. Moving large numbers of objects places a high burden on the virtual machine and can lead to temporary freezes. Mostly this occurs when the virtual machine is enlarging the heap.
The number of threads in the virtual machine, split in active and inactive threads. This is useful if you create a large number of threads and need information on changes in their total number and how many of them actually run.
What's New in This Release: [ read full changelog ]
· This version adds support for Java 7 (class files compiled with -target 1.7), "Copy to clipboard" buttons on the detail panels for "Fields" and "Methods", as well as quicklinks for opcode documentation at the bottom of the bytecode display.