Performance Tuning
Performance Tuning
Memory Leaks
Java Performance
Most of the applications today are designed and developed for simultaneous use by a large number of users. At times there are underlying problems in the code, which may cause error conditions such as Memory leaks, Race conditions, Thread locks and so on which if neglected, stretches the use of resources beyond limits, causing the application to slow down or even crash. Profiling can help you detect these problems and help you optimize your Java applications. We will try to understand few important aspects with Java Profiling. Following document will help you understand what Java Profiling means, why Java Profiling is required and how you can successfully implement Java Profiling for your Java applications using AppPerfect.
cycle. Java Profiling must be performed before the code is finally executed and deployed to identify critical issues that affect the stability and quality of the software. Java Profiling may thus be summarized as measuring statistics of a Java application, specifically in terms of:
CPU time being utilized per method Memory being utilized Method call information Objects being created Objects being garbage collected
New Java Profiling project. For details on New Project creation refer to Creating a New Project chapter. For details on configuring project properties refer to Setting Project Properties chapter. 2. Provide the Name of the project and select the "Target" tab to configure your target application for profiling. You can either profile Server/Web application or can choose to profile Load/Desktop application. In this tab you need to configure the Run Configuration for target application. Server applications are typically applications that are deployed in a J2EE application server such as BEA WebLogic, IBM WebSphere, JBoss, Apache Tomcat, Oracle Server, SunOne etc. Local/desktop applications typically run on your local machine as a single user system. For details refer to Configuring Target Application Settings chapter.
3. Once you are done setting up project, select Project -> Run menu option to start profiling Java application. For details refer to Profiling an Application chapter.
Specifically, the Heap snapshot provides a summary of the classes, instances, allocations, outreferences and in-references of the objects that are held in the heap at a particular time. To take Heap Snapshot select the Project -> Take Snapshot... menu option. After the snapshot is taken, a list of classes/objects present in the heap at the time of taking the snapshot can be seen, the details of any class/object can be viewed by double clicking it. For details on Heap Snapshot refer to Heap Browser chapter.
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. You can also view the details on Garbage collection, the objects which are garbage collected and the time consumed during garbage collection. All the views are updated in real-time providing the profiling data immediately as your application is running. The Memory Profiling views can be accessed from the Navigation Tree by selecting the Memory Profiling node. For details refer to Memory Profiling chapter.
unchecked memory growth which will slow down your application and eventually crash it. Memory Leak Scenarios feature is designed to help detect possible memory leaks in your application. To start the scenario click on Start Scenario toggle button. AppPerfect Java Profiler will force a Garbage Collection and register all live objects present in memory after the GC. Perform actions in your application based on your usage scenario. Once you have finished executing the scenario, click on the Stop Scenario toggle button. AppPerfect Java Profiler will again force a Garbage Collection and will register all live objects in memory after the GC. It will then find out differences in the live objects between start and end of scenario. Objects that are created during the scenario run but not disposed by Garbage Collection are shown in the Scenario details tab. To further investigate and trace these objects, take a Heap Snapshot and concentrate on only those classes for which the leaked objects are reported. The Memory Leak Scenarios view can be accessed from the Navigation Tree by selecting the Memory Leak Scenarios node. For details refer to Java Memory Leak Profiling chapter.
On-Demand Profiling :
Profiling a JVM requires the profiler to connect to and collect all relevant information from the running application. This is generally done during development stage. This type of profiling is 'Development mode' profiling. However, it has been observed that often an application profiled during development does not throw up issues, but after deployment, it does. In such cases it becomes necessary to profile the production JVM directly. Therefore to address the needs for profiling an application that is already in production, AppPerfect Java Profiler provides "Ondemand" profiling. On Demand or Production mode profiling allows you to profile your deployed application. This is different from Development mode profiling, where you profile your under-development application. On-demand profiling can be defined as profiling of the JVM of a deployed application as and when required without the need to start and stop the JVM along with the profiling. This reduces your system overheads to a great deal as you can start the application
to be profiled once and then connect to it for profiling 'on-demand' without having to stop it when you wish to stop profiling or re-start to profile again. To change profiling type to OnDemand mode, select Project -> Properties.. menu option and under Profiling Type tab change the option to On-Demand profiling. Development mode Profiling collects more information about the target JVM being profiled as all the methods are always under the Java Profiler's purview. However, in On-demand profiling, the Java Profiler collects information only from the methods that have been launched and are active during profiling session.
Integrate Java Profiling with your Daily Build Process with ANT Script and Command line Support:
AppPerfect supports integration with build process smoothly. You just need to export Java Profiling project as ANT Script or Command Line script and then you can execute these exported scripts from your build process. This way you can ensure that each build is profiled before final deployment. To Export project as Ant Script select Tools -> Export Project as ANT Script... menu option. For details on ANT script execution refer to ANT Script Execution chapter.
Conclusion :
AppPerfect Java Profiler helps you diagnose and resolve performance problems, memory leaks and multi-threading problems in your Java or J2EE server applications to ensure the highest level of stability and scalability for your applications. AppPerfect Java Profiler provides you with a root-cause analysis of these problems and helps you resolve them. AppPerfect Java Profiler provides you a unified view of all resources that is memory, methods, threads and monitors to help you understand your JVM's behavior, performance characteristics etc. to reach to bottom of problem quickly. AppPerfect Java Profiler is a comprehensive Java performance tuning solution with support for Heap Analysis, Thread Analysis, Monitor analysis and Deadlocks detection. It is one of the best and finest profiler available in the large market of profilers.AppPerfect Java Profiler is found to be most affordable, cost effective, efficient, reliable and accurate profiling solution by its customers. In case you have not yet tried AppPerfect Java Profiler, Download Now and give it a try today.
JAVASIMION: http://code.google.com/p/javasimon/wiki/Introduction
Introduction
Application performance measurement is pretty old discipline and we are sure that most developers already tried to measure performance in some way. Maybe you have tried it because some obvious optimization went wrong, maybe because your application was really slow and maybe because you just wanted to track the performance for whatever reason. Java Simon API is developed to help you to track your application to measure parts you are interested in and to process these observations somehow. To achieve that the code must be infected by various monitors on various places. It's not the goal to put monitors everywhere, it's up to you the developer to decide what you want to measure. Aside from your needs there might be additional business needs you want to answer with such a monitoring as well. (You may find useful to check Java run-time monitoring three-part article to see where Java Simon fits in: http://www.ibm.com/developerworks/library/j-rtm1/index.html)
profiling solves primarily performance problems, trying to localize the cause of the slowness; profiling is mostly development-time tool, it is used mostly when the problem occurs and its results are most important for developers;
profiling has often dramatic impact on the performance and is rarely used in production.
you know what you intend to measure and you place monitors exactly where you want; you probably plan to track measured metrics for some time and process them later to see them from the perspective, review trends, etc.; results might be important for developers as well as for administrators or business staff.
Of course both worlds intersect in many areas and Simon API has also some functions that are close to profiling. Still there is the difference that the application with Simon profiling (for instance usage of the Simon JDBC proxy driver) can run in the production unless the performance is critical. This way you can track things that are hard to track during typical development-time profiling. For instance you can be hunting some nasty resource leak that will likely not occur during short-term test. Monitoring with Simon API is not performance tuning in the first place it is monitoring. That does not mean you cannot use the results to tune the performance. Simons allow you to watch your application and it is up to you how you intend to use those results.
micro-benchmarks! But than... it would not be exactly the reason why Java Simon project was found. Java Simon was created to make Java application monitoring more fun, more useful and in the first place to make it easier.