Profiling an Application

Profilers are used to detect errors such as memory leaks and to find bottlenecks in your code. It helps you improve the stability, increase the efficiency and raise the overall performance of your application. Profiling thus saves you countless man hours as it pinpoints the problems in your product and provides highly accurate and complete information of problems in your application.

Profiling Defined

AppPerfect Java Profiler profiles the target JVM, using JVMTI/JVMPI events provided by the JVM. JVMTI/JVMPI is an interface between the JVM and the profiling controller. The JVM sends a notification of various events such as method calls, heap allocation and so on to the profiling controller and the controller sends control requests through the JVMTI/JVMPI to the JVM.

Profiling is the process of monitoring various JVM level parameters such as Method Execution, Thread Execution, Object Creation and Garbage Collection. It will provide you with a finer view of your target application execution and its resource utilization.

When creating a project, instead of monitoring all aspects of the application, the project can be configured to monitor only a small part of the application. Any project can be customized to do only CPU Profiling to observe only method attributes like Execution Time, Invocation Tree or Hotspots. To keep a check on Thread properties, while your target application is running, turn on Thread Profiling. Memory Profiling provides information on the various classes, instances and analyzing memory leaks.

The specialized views like Memory and Hotspots will help you in analyzing the problems in the target application like memory leaks and execution bottlenecks. Following topics provide links to the different aspects of profiling an application describing in brief the different views.

Start, Pause or Stop profiling

 Menu bar: Click Project -> Run or  Project -> Pause or Project -> Stop

When you start profiling, you can immediately see the summary charts getting generated in the right hand pane. In the left hand pane, you can see listed all the parameters that are being profiled. You can click any of these to view in more detail.

Project Summary

The Project node in the navigation tree provides a consolidated view of the charts. You get a bird's eye view of the heap consumption of the application being profiled. To view details of how the heap is allocated, visit the various detail nodes in the tree.

Heap Memory

Memory chart provides a clear view of how much of the total memory is allocated on the heap. It provides information useful for you to detect any memory leaks in your application. For example, if the objects are not being garbage collected will cause an increase in the memory used and the same is indicated in the chart that rises steadily with time and after reaching its maximum allowable limit it finally throws an 'out of memory' error. This indicates that there is a memory leak in the application. If the application is able to maintain a reasonable memory usage within the total memory constraints, it indicates that no memory leaks are present.

Memory chart is plotted with the time stamps on the X-axis and memory usage (in Kilobytes) on the Y-axis. The total size of the heap is also plotted on the Y-axis to provide an indication of the amount of memory being allotted.

Thread Count

Here you can see the number of threads in the application, highlighted by the state they are in: running, waiting or blocked. Number of threads is plotted on the Y-axis and the X-axis displays the time.

Object Instances

The Objects chart gives an idea of the number of objects and arrays being created by the profiled application at any given point in time. You can perform a certain action in your application and view the chart to see the immediate reaction of your application to that event. It is plotted with the time stamps on the X axis and the number of live instances created on the Y axis.

Heap Browser

The Heap Browser gets activated when you take a Heap Snapshot. A Heap Snapshot is all the information in the JVM at a given instance of time, which includes all the classes, their instances their allocations and their references. For more information, please see the chapter Heap Browser.

Memory Leaks

This is a new feature from AppPerfect version 6.0 and later. You can now create scenarios in which you can detect memory leaks. A lot of information about this is available in the UI.

Memory Profiling

Effective memory management ensures optimized performance from any application. The Memory node holds the information about the memory used by your application. It shows the number of objects, the method that created them, the size of the objects and the status of the objects. This information is presented in the form of charts and tables for easy interpretation and clearly shows the high memory consumption areas of the application. For further details refer to the Memory Profiling chapter.

CPU Profiling

CPU Profiling includes monitoring the methods and performance hotspots. The Methods node provides information of the CPU usage of the application. The performance of an application is measured in three ways, the application's memory usage, the time spent in carrying out a task and the hotspots or bottlenecks present in an application. This information gives knowledge of the exact amount of time that the CPU spends processing the application methods and whether or not there are any hotspots present in the application. For further details refer to the CPU Profiling chapter.

Thread Profiling

Use of multiple threads is essential to build scalable and reliable applications. Working with multiple threads brings up other issues such as concurrency and contention over resources. The Threads node holds information about the threads used by the application that is being profiled. These reports show the state of the threads, monitors, and deadlocks if any. Observing the thread charts and tables, you get information on the performance of your application. For further details refer to the Thread Profiling chapter of the documentation.

Open with Java Editor : View Source Code

This option is available only if the Source Path is provided for the project. You can do that in the Source tab while defining a new project or from Project -> Preferences -> Source

The java source code opens up in the default Eclipse Editor. The source code can be accessed as follows:

1.       The Methods Details or Hotspots of the CPU node. This opens the java source file and highlights the selected method.  

2.       The Classes or Method wise Allocations of Class Browser of the Memory node and of the Heap Browser. This only opens the source file.

Console Messages

The Console Messages Window shows all console messages. There are two console message windows: Console and Server Console in case you have created a project Server / Web Application. You can close consoles by clicking on the cross mark at the right-hand corner of the window. Right click inside the window to 'Save', 'Clear' and 'Hide' the results of the compilation. These console views shows the console-output.