SAP Memory Analyzer: Multi-Gigabyte Java Heap Dumps Are Nothing to Fear Now

Similar documents
MDM Syndicator Create Flat Syndication File

Visual Composer - Task Management Application

SAP GRC Access Control: Configuring compliant user provisioning (formerly Virsa Access Enforcer) into CUA Systems

What s New / Release Notes SAP Strategy Management 10.1

Consuming Web Dynpro components in Visual Composer.

Cache Settings in Web Page Composer

Visual Composer Build Process

A Step-By-Step Guide on File to File Scenario Using Xslt Mapping

Install TREX for CAF Version 1.00 March 2006

How To Configure the Websocket Integration with SAP PCo in SAP MII Self Service Composition Environment Tool

Web Page Composer anonymous user access

Data Validation in Visual Composer for SAP NetWeaver Composition Environment

Do Exception Broadcasting

How to Use Function Keys in Mobile Applications for Handhelds

How to Create a New SAPUI5 Development Component

Quick Reference Guide SAP GRC Access Control Compliant User Provisioning (formerly Virsa Access Enforcer): HR Triggers

WDA - Custom themes for Web Dynpro ABAP applications without SAP Enterprise Portal integration

How To... Configure Integrated Configurations in the Advanced Adapter Engine

How To Recover Login Module Stack when login to NWA or Visual Administrator is impossible

How to Translate a Visual Composer Model Part I

How To... Reuse Business Objects and Override Operations of a Business Object

How to Upgr a d e We b Dynpro Them e s from SP S 9 to SP S 1 0

How To... Master Data Governance for Material: BADI USMD_SSW_SYSTEM_METHOD_CALLER to create successor change request

How To Set up NWDI for Creating Handheld Applications in SAP NetWeaver Mobile 7.1

Integrate a Forum into a Collaboration Room

SAP NetWeaver How-To Guide

configure an anonymous access to KM

How to Set Up and Use the SAP OEE Custom UI Feature

How To...Configure Integration of CUP with SPM

Building a Tax Calculation Application

How To... Promote Reports and Input Schedules Through Your System Landscape

Enterprise Portal Logon Page Branding

How to Browse an Enterprise Services Registry in Visual Composer

link SAP BPC Excel from an enterprise portal Version th of March 2009

How To... Master Data Governance for Material: BADI USMD_SSW_PARA_RESULT_HANDLER to merge result of parallel workflow tasks

Process Control 2.5 Implementation Checklist

Create Partitions in SSAS of BPC Version 1.00 Feb 2009

BusinessObjects Enterprise XI 3.0 with Complex NAT Networks

How to Set Up and Use the SAP OEE Custom KPI Andons Feature

SAP MII: Leveraging the Data Buffering Feature for Connection Error Handling.

How To Extend User Details

SDN Contribution HOW TO CONFIGURE XMII BUILD 63 AND IIS 6.0 FOR HTTPS

xmii UDS Overview and Troubleshooting

View Time Security for crystalreports.com

Configure TREX 6.1 for Efficient Indexing. Document Version 1.00 January Applicable Releases: SAP NetWeaver 04

Preview of Web Services Reliable Messaging in SAP NetWeaver Process Integration 7.1

How-To... Add Sensitive Content into an Area

How To...Use a Debugging Script to Easily Create a Test Environment for a SQL-Script Planning Function in PAK

How To... Master Data Governance for Material: File Down- and Upload

Simplified Configuration of Single System Update in Maintenance Optimizer

Extracting Product Attributes in XML using Web Service

Introducing SAP Enterprise Services Explorer for Microsoft.NET

Visual Composer for NetWeaver CE: Getting Started with a Typical Workflow

SAP NetWeaver How-To Guide How to use Process Execution Manager Using SAP Test Data Migration Server

Configure SSO in an SAP NetWeaver 2004s Dual Stack

How To Troubleshoot SSL with BPC Version 1.01 May 2009

Monitoring System Landscapes Using the DBA Cockpit

Extract Archived data from R3

How to View Dashboards in the Self Service Composition Environment with Additional Metadata

How To Configure IDoc Adapters

How To Generate XSD Schemas from Existing MDM Repositories

Working with Select Options in Web Dynpro for ABAP

SAP NetWeaver How-To Guide

Installation Guide Business Explorer

Create Monitor Entries from a Transformation routine

Transport in GP. How-to Guide Beginning with SAP NetWeaver 2004s SPS06. Version 2.00 January 2006

SAP NetWeaver How-To Guide. SAP NetWeaver Gateway Virtualization Guide

SAP Composite Application Framework. Creating a Content Package Object

Value Help in Web Dynpro ABAP - Tutorial.

Create Monitor Entries from an update routine

JMS Clustering and Failover

Configure UD Connect on the J2EE Server for JDBC Access to External Databases

How to Use Definitions in Rules Composer

Access Control 5.3 Implementation Considerations for Superuser Privilege Management ID-Based Firefighting versus Role-Based Firefighting Applies to:

Building Custom Applications Using IBOM

The test has been performed using a 64 Bit SAP NetWeaver Application Server Java 7.1 Enhancement Package 1 SP4 or greater system.

Configure Peripheral Drivers with Mobile Infrastructure

How To Develop a Simple Web Service Application Using SAP NetWeaver Developer Studio & SAP XI 3.0

How To...Custom BADI for rounding off values in SAP BUSINESSOBJECTS Planning and Consolidation, version for SAP NetWeaver.

Setting Up an Environment for Testing Applications in a Federated Portal Network

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 2

Consuming Directory API in ABAP

What's New in the DBA Cockpit with SAP NetWeaver 7.0

Work with Variables in SAP NetWeaver Visual Composer Version 1.00 May 2006

Duet Enterprise: Tracing Reports in SAP, SCL, and SharePoint

Using Tools to Represent Appraisal Status Flow (HR module Objectives Settings and Appraisals ) as Diagram

How to Use Other Conditions in Decision Tables in Rules Composer

Use Business Objects Planning and Consolidation (version for the Microsoft platform) BPF services in Xcelsius

Simplifying the Capturing, Evaluation, and Communication of Class-Based Exceptions

Setting up Single Sign On Between xmii and Enterprise Portal

SAP BPC 5.0 & 5.1 Performance and Reliability tips

SAP How-To Guide. Master Data Governance for Material. How To... Adjust MDG Homepage. Applicable Releases: EhP6, MDG 6.1

How To Customize the SAP User Interface Using Theme Editor

Line Items in BI Integrated Planning

Business Rules Framework plus Workbench

How To Use Surveys with Mobile Sales for handheld Version 1.00 January 2007

SAP - How-To Guide MDG Custom Object Data Replication How to Configure Data Replication for MDG Custom Objects (Flex Option)

Hardware Requirements

SAP NetWeaver 04. Unification Terminology

How To Integrate the TinyMCE JavaScript Content Editor in Web Page Composer

Transcription:

SAP Memory Analyzer: Multi-Gigabyte Java Heap Dumps Are Nothing to Fear Now Applies to: Java development in general Summary SAP has developed a tool for Java memory analysis which is helpful to all Java developers in general, not only to those building Software on top of SAP products like SAP NetWeaver for Java. It was presented at JavaOne 2007 in a technical session and is now available for free download on SDN. Please read this article to find out why we think this tool makes a difference and is worth working with. More technical and problemoriented articles will follow soon. Author(s): Vedran Lerenc Company: SAP AG Created on: 21 January 2007 Author Bio Vedran is a Development Architect in the Java Server Technology group of SAP AG. He started to work professionally in 1994 with IBM at the European Networking Research Center in Heidelberg. He left and co-founded MetaKey Inc. in 1998 developing an OODBMS. In 2000 he joined SAP AG in Palo Alto, later in Walldorf where he is currently researching and developing tools for memory and thread analysis in Java. 2007 SAP AG 1

Table of Contents Introduction... 2 Use Case... 2 Procedure... 2 Features... 3 Leak or Footprint... 5 Synopsis... 6 Related Content... 6 Copyright... 7 Introduction To put it short, the SAP Memory Analyzer is a tool for Java memory analysis or more precisely an Eclipse-based application which allows you to inspect a Java HPROF binary heap dump very efficiently and effectively, because it is both, fast in execution and helpful in analysis. The tool was developed to analyze real productive heap dumps which tend to get enormous in size with hundreds of millions of objects. High Performance, low resource consumption and especially its analysis techniques make it a unique tool, powerful also to small application heap dumps. Please see our Java Memory Analysis page on the SDN Wiki for more information, performance numbers and a complete feature list. Use Case Java VMs of Sun, HP, SAP and some other vendors can be configured to write heap dumps on the first thrown OutOfMemoryError (OOM). Such a heap dump basically contains all the Java Objects including their field values and references among them and is helpful to understand the state of the application at the time the Java VM run out of memory. You can open those heap dumps with the SAP Memory Analyzer and inspect them in detail. The SAP Memory Analyzer won t tell you when and by whom the objects were allocated, because this information is not present in the heap dump. Also, you will only see the live objects, i.e. you won t see the objects which have been allocated and garbage collected in the past. Again, this information is not present in the heap dump. What you will see are all the Java Objects which couldn t be garbage collected at the time the heap dump was written, along with the information who keeps them alive, their size and more. Procedure The easiest way to get a heap dump is to get one on OutOfMemoryError (OOM). This feature is available since version 1.4.2_12, 5.0_7 and 6.0 and can be switched on with the following VM parameter: -XX:+HeapDumpOnOutOfMemoryError There are some more means to get a heap dump on demand, but they depend on the platform/version of the Java VM. Please have a look at our Wiki for more information on this topic. Our Wiki also gives you the download link to the SAP Memory Analyzer and information on how to install it. You will find the download link at the end of this article, too. Even though we offer only a Windows 32 bit installer, you can read on the Wiki on how to set up the tool for your platform, as long as it is supported by the Eclipse platform. When you have a heap dump and open it for the first time in the SAP Memory Analyzer, the tool will parse the heap dump. Parsing is in our case the process of building up index files for the most important properties of the heap dump, e.g. the size of each and every object, where it is found in the heap dump, which objects 2007 SAP AG 2

reference it or which objects are referenced by it. This happens only once. When you reopen the heap dump, it opens instantly. Other tools read/parse the heap dump again and again when you reopen it. Parsing is a relatively expensive operation. We optimized the parsing a lot, but for large heap dumps above 2 GB you will usually need a bigger box. However, as written above, this happens only once. If you have your index files, you can analyze even extremely large heap dumps on a smaller, let s say 32 bit machine and hand the heap dump along with the index files around to other users, e.g. from support to development or from one developer to another. After the parsing process the real intellectual work for the user starts: The analysis of the heap dump. The tool supports the user with a rich set of features, allowing also users not familiar with the source code to identify the problems. Features After opening a heap dump you will see some basic numbers about the heap dump itself and a basic class histogram on the first page. A class histogram lists all the classes which were found in the heap dump and the number and size of instances of them. This is nothing special as all tools more or less offer such a view. You may jump to the list of objects, inspect the objects on the left hand side in the object inspector, but this is again boilerplate functionality heap walking. 2007 SAP AG 3

Only in less than 5% of the cases this view tells you what exactly is wrong, but it gives you an overview. E.g. you might get irritated if you see too many instances of java.lang.string, let s say 10 million of them, but it doesn t tell you much more. What can you do from there next? Follow each reference to each instance manually to detect a pattern? That would be pretty time consuming if not useless. The SAP Memory Analyzer did something during parsing which will help you a lot during analysis. It transformed the graph of objects into a tree of objects a dominator tree. This dominator tree has a very important property: Each object in the tree dominates its children, meaning, it keeps them alive. All children are alive because of this single object in the tree above them. Dominator trees point immediately to the biggest distinct object sets. You can explore their content as you like. You can also do it vice versa, take the instances of java.lang.string I have mentioned above and look up their dominators and group them by class. An aggregation pattern, i.e. systematic behavior behind your memory will immediately become visible in the dominators. You can even filter out objects you are not interested in, e.g. to know that some or many Strings were hold in HashMaps is not interesting, but skipping those collection references or generally instances of classes from the java.* packages in the dominator chain until you reach an instance of a class of your company or your customers tells you a lot more. It is important to note here that this approach is not to be confused with heap walking. Usually if you take an object and look what it references you will see that it references half of the heap through some reference chains, e.g. an object references implicitly its class which references implicitly its class loader which references the classes defined through it which reference static fields and so on. In reality following the object references doesn t help you for a set of objects. With the dominator tree, however, this problem is 2007 SAP AG 4

solved elegantly. In a tree you have only one parent and in the dominator tree this parent is the single object which keeps all its children alive. Dominators have some more very helpful properties which we have exploited in the tool, but we won t go into more details in this article and conclude this brief feature tour with the most common final question in analysis: Who holds your problematic chunk of memory alive? Which key object or thread is it? Independent of the means you have used to spot the memory problem, through the dominator tree as you have seen above or through some different means, e.g. through our query language or our textual console, you are interested to see the real reference chain from the roots, e.g. from the thread(s). This can be done by a view which shows you all the paths from the roots to your object or object set of interest. I picked those three features/screenshots just to highlight the basic approach in analysis, which is 1.) about getting an overview, 2.) finding your problematic memory and 3.) analyzing who keeps it alive, but there is much more to explore in the tool than this. We will cover more functionality, tips and hints in further articles, blogs and posts. Leak or Footprint Having read the above you might think that memory leaks are the problem this tool addresses primarily, but in reality memory leaks are comparatively easy to detect and fix if the leak can grow over time. However, in a Java application server with hundreds or thousands of deployed applications memory footprint problems are far more threatening, as all deployed applications together burden the server. Wasted memory may be 2007 SAP AG 5

hidden everywhere and the SAP Memory Analyzer helps to uncover most of them, e.g. by views showing the memory consumption per class loader which is usually the equivalent of a deployed application in an application server. Synopsis SAP Memory Analyzer supports Java developers in general with new analysis techniques, as well as SAP customers with specific SAP NetWeaver CE views. It helps to analyze small Java application heap dumps, as well as extremely large Java application stack heap dumps like those from productive JEE systems. It is now available for free download on SDN. SAP doesn t charge money for it, nor limits its functionality, but doesn t offer support for it, except if you are a SAP NetWeaver CE customer. However, we like to receive your feedback and will actively participate in discussions on the Internet. Please visit our Wiki for more details. Related Content Wiki Page: https://wiki.sdn.sap.com/wiki/x/k2w Download Link: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/8070021f- 5af6-2910-5688-bde8f4fadf31 Slides from our JavaOne 2007 Technical Session: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00ca7f0d-8ee6-2910-5d82- fc3e8dd25300 Live Recording and Transcript from our JavaOne 2007 Technical Session: http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=ts-21935&yr=2007&track=5 Java Programming Forum at SDN: https://www.sdn.sap.com/irj/sdn/forum?forumid=59 2007 SAP AG 6

Copyright Copyright 2007 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iseries, pseries, xseries, zseries, z/os, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/os, POWER, POWER5, OpenPower and PowerPC are trademarks or registered trademarks of IBM Corporation. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mysap, mysap.com, xapps, xapp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages. Any software coding and/or code lines/strings ( Code ) included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent. 2007 SAP AG 7