IBM® HeapAnalyzer

 

 

IBM HeapAnalyzer Creator/Architect/Developer

Jinwoo Hwang

jinwoo@us.ibm.com

 

Welcome to IBM HeapAnalyzer. IBM HeapAnalyzer allows the finding of a possible Java™ heap leak area through its heuristic search engine and analysis of the Java heap dump in Java applications. You can find more information at http://www.alphaworks.ibm.com/tech/heapanalyzer

 

Introduction

The Heapdump contains a list of all the objects that are in the heap.

Heapdumps can be very large with millions of items in them.

It's not always easy to analyze a large file. This tool analyzes heapdumps of Java SDK 1.3.1,1.4.x, 5.0 and 6.0

IBM HeapAnalyzer is provided “as-is”.

Supported features of IBM HeapAnalyzer are ported to MDD4J which is available in IBM Support Assistant (http://www-306.ibm.com/software/support/isa/). MDD4J is an incorporation of IBM HeapAnalyzer and other IBM Java heap analysis tools.

Prerequisite

·       Java Runtime Environment 5 or higher

The following exception will be thrown if older version of Java virtual machine is used:
Exception in thread "main" java.lang.NoClassDefFoundError: java/util/regex/PatternSyntaxException

 

Definitions

·       Root object An object for which no (different) object holds a reference.

·       Parent object An object (for example, A) that holds at least one reference to some
(different) object (for example, B). In this case, A is said to be the parent of B.

·       Owner object If an object has more than one parent object, a parent object is chosen as owner object.
Total size is calculated only with owner objects.

·       Child object An object (for example, B) for which at least one (different) object
(for example, A) holds a reference. In this case B is said to be the child of A.

·       Type Collection of same objects

·       Size The size of an object is the amount of memory that is required to hold that object in memory.

·       Total size The subtree size of an object is the sum of its size and the sizes of
all the objects that it reached from its children. Note that each
object is assigned a unique parent and root during processing.
If there’s substantial difference in total size between
a parent and its child, it’s called a total size drop.

 

Features

·       Parent and Children View from Table View and Tree View

·       Address search

·       Root List View

·       Same Type View

·       Configuration restore and save

·       IBM, Solaris®, and HP-UX® Java 5.0 ascii/binary Java heap dump support

·       IBM, Solaris, and HP-UX Java 6.0 ascii/binary Java heap dump support

·       Look and Feel option

·       Automatic detection of truncated heap dump

·       Java Profile v1.0.1 ascii and binary Java heap dump support

·       Solaris hprof 1.0.1 binary Java heap dump support

·       heapdump file command line support. See “How to run this tool” section

·       Supports IBM portable heap dump .phd format as well as IBM heap dump .txt and .txt.gz

·       Automatically detects file format

·       Supports Console window

·       Creates a tree from heapdump

·       Calculates size of each objects

·       Calculates total size of each subtree

·       Finds total size drop in a subtree

·       Shows gaps between objects by size

·       Shows objects by size

·       Shows objects by total size

·       Shows objects by number of child

·       Shows types by size

·       Shows types by count/frequency

·       Shows types alphabetical order

·       Shows gap distribution chart

·       Shows detailed information of an object

·       Finds type with regular expression

·       Drag and drop support in input fields, tree and text

·       Bookmarks in tree navigation

·       Locates possible leak suspects

                                                                        

How to run this tool

You need to use the Java 2 Platform, Standard Edition version 5 or higher Java Runtime Environment (JRE) to run this tool.

Usage <Java path>java –Xmx[heapsize] –jar ha<HeapAnalyzer version>.jar <heapdump file>

For example, /usr/java50/bin/java –Xmx1000m –jar ha146.jar heapdump1234.txt

If there’s java.lang.OutOfMemoryError while you are processing heapdumps, please try increasing the maximum heap size (-Xmx) value to give the JVM more memory.

Maximum heap size should not be larger than the size of available physical memory size for this tool due to performance issue.

Feel free to contact me if you have any comments or suggestions.

 

 

1. Start the HeapAnalyzer

 

 

[Initial screen]

 

2. Select File -> Open and select a heapdump file

 

 

Select IBM heap dump text file, IBM portable heap dump, Java Profile V1.0.1 ascii/binary Heap Dump or HeapAnalyzer processed file to process a heap dump.

 

 

3.  Progress is shown during processing heapdump.

 

 

 

4. It would take lots of time if you are processing large heapdump. The following is the screen when processing is complete. Please do not close this window until you do not need this heapdump.

 

 

 

Memory leak suspects are compiled under “Subpoena Leak Suspect(s)” menu in Tree View. 

 

 

If there’s no memory leak suspect, Tree View is not displayed by default.

 

 

Click on Analysis menu and select Tree view menu item to display heap tree.

 

 

5. The following is tree view of the heapdump.

The icon, ,  indicates that it has already been included as a child object of owner object in tree view

Each tree node as in the following format:

TotalSize(TotalSize/HeapSize%)[ObjectSize] NumberOfChildObject(Number of root objects) Name Address

 

 

 

 

6. In tree view, you can see detailed information of a node , you can search for total size drop between parent and child

or you can find an address by selecting a node and click on right mouse button.

 

 

“Search for total size drop” will find a size drop between the total size of a parent

and the biggest total size of child of the parent.

If you cannot find any size drop from the menu “Search for total size drop”, you need to decrease

Minimum total size drop for search in options.

 

 

 

You can find an address in the tree view by selecting the menu “Find an address”

 

 

The following is the result of address search :

 

 

 

7.  If you want to review detailed information regarding a node, just click and you will have the information on he right pane. Or you can select the following menu.

 

 

The following is the screen of detailed node information in heapdump tree

 

 

 

8. You can put bookmarks to save a location and continue to navigate tree by selecting “Add Bookmark”.

 

 

 

Bookmarks are stored in “Go to Bookmark” Menu in Tree View menu bar.

You can go to the saved locations in tree by clicking bookmarks

 

 

 

Bookmarks can be deleted by clicking them in “Remove Bookmark” Menu.

 

 

 

9. If there are lots of children in a tree, you can see “There are NNNN more children” at the bottom of the tree.

You can see more children by expanding the node.

 

 

 

You can also use “Show more children” Menu from parent nodes.

 

 

Now you can see more children.

 

 

 

10. You can locate a possible leak area by using “Locate a leak suspect” Menu.

 

 

Suspected leak area is displayed as follows.

 

 

 

 

 

The icon ,, indicates that it’s not a root object/class and there are parents for this node.

If you want to display more parents, you can select the menu, “Show more parents”

If you want to display from root objects, you can select the menu, “Show from roots”

 

 

 

If you want to see all the objects with the same name, select “List same type” from the menu:

 

 

The following is the result of the query:

 

 

By clicking on right button of your mouse, you can locate a specific object in tree view and you can find parents or children of a specific object.

 

 

11. Display objects sorted by Total Size.

 

 

 

Objects are displayed and sorted by total size.

 

 

By clicking on right button of your mouse, you can locate a specific object in tree view and you can find parents and children of a specific object.

 

 

If you click on column header of TotalSize, the column will be sorted in reverse order.

 

 

 

12. List objects sorted by their sizes

 

Objects are sorted by sizes by clicking on Size column header.

 

 

 

 

13. List objects sorted by number of child

 

Objects are sorted by number of child by clicking on No. Child column header.

 

 

Click on Address column header to sort objects in address order.

 

 

Click on Object column header to sort Object in alphabetical order.

 

 

 

You can also move each column to different locations. Address column was moved next to TotalSize column in the following screen.

 

 

14. List types sorted by size

 

 

 

Types are sorted by sum of sizes.

 

 

By clicking on right button of your mouse, you can find objects with the same name of a specific object.

 

 

 

15. List types sorted by frequency/count

 

 

 

16. List types sorted by alphabetical order

 

 

Select Root List to display root objects.

 

 

All root objects are displayed as follows:

 

 

 

By clicking on right button of your mouse, you can locate a specific object in tree view and you can find same types, parents and children of a specific object.

 

 

 

16.  List gaps between objects sorted by size

 

 

 

The following is gaps between objects view by size

 

 

 

17.  Display gap statistics.

 

 

 

Gaps distribution chart. Do not assume gaps are free spaces. Gaps are literally gaps between two objects. Java heap dumps do not have any information about what they are.

 

 

18. You can configure setting by selecting View -> Options menu

 

 

 

 

“Avoid Soft/WeakPhantom Reference” option creates trees that avoid Soft/Weak/Phantom References as owner objects. This option requires more memory and should be enabled before you open heap dumps.

 

 

 

19.  Search for objects/types and sort them by total size.

 

 

 

Enter objects/types name in regular expression. Uppercase/lowercase matters!!

 

 

The following is the list of types which have “byte” in their names.

 

 

 

20.  Search for objects/types and sort them by size.

 

 

 

The following is the list of types which have “byte” in their names, sorted by number of child.

 

 

By clicking on right button of your mouse, you can locate a specific object in tree view and you can find same types, parents and children of a specific object.

 

 

21. By entering exact name, we can review detailed information regarding specific types.

For example, you can enter exact name of a type: byte[]

 

 

 

The following is the list of types of byte[] as well as detailed information regarding byte[]

The column headers have more information.

Sum of TotalSize is 117,712 bytes. Sum of Size is 117,712 bytes.

There are 140 objects of byte[]

 

 

You can find a specific address by selecting Search Address

 

 

Enter an address of an object

 

 

The following is the result of address search

 

 

By clicking on right button of your mouse, you can locate a specific object in tree view and you can find same types, parents and children of a specific object.

 

 

22. You can hide/show status bar.

 

 

 

23. You can hide/show Console.

 

 

Exceptions/Errors from HeapAnalyzer

 

·       OutOfMemoryError
     
      Increase –Xmx up to maximum available size for your environment. If you reach 32 bit address space limit on 32 bit Java virtual machine, 64 bit Java virtual machine is recommended for large Java heap dumps. In most cases, about 1500MB is maximum practical size for –Xmx on 32 bit Java virtual machine on Windows® operating systems. For example you might want to use 64 bit Java virtual machine for a PHD Java heap dump with file size of 500MB.

·       Exception in thread "main" java.lang.NoClassDefFoundError: java/util/regex/PatternSyntaxException

HeapAnalyzer requires Java virtual machine version 5 or higher.
The exception is thrown if older versions Java virtual machine is used:

·       java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(Unknown Source)
        at com.ibm.jinwoo.heap.FileTask$ActualTask.<init>(FileTask.java:386)
        at com.ibm.jinwoo.heap.FileTask$1.construct(FileTask.java:794)
        at com.ibm.jinwoo.heap.SwingWorker$2.run(SwingWorker.java:45)
        at java.lang.Thread.run(Unknown Source)

        You can see this exception while processing corrupted heapdumps or truncated ones. Truncated or corrupted heapdumps are not reliable.

·       Exception while parsing line 9 : 0x0x50003070 [1000] java/lang/String
java.lang.RuntimeException
        at com.ibm.jinwoo.heap.FileTask$ActualTask.<init>(FileTask.java:321)
        at com.ibm.jinwoo.heap.FileTask$1.construct(FileTask.java:794)
        at com.ibm.jinwoo.heap.SwingWorker$2.run(SwingWorker.java:45)
        at java.lang.Thread.run(Unknown Source)

Some old IBM SDKs generate invalid address in heapdumps. After replacing 0x0x with 0x, HeapAnalyzer can process heapdumps.

·       Format error while parsing line 10 :   0x50004050 0x50004050

Unexpected format in heapdump. Possibly it’s corrupted heapdump. Further analysis is unreliable.

   

 

 

Copyrights and notices

(C) Copyright IBM Corporation 2003-2009. All Rights Reserved. Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

AIX, Cloudscape, DB2, IBM, iSeries, OS/390, WebSphere, and z/OS are trademarks or registered trademarks of IBM Corporation in the United States and/or other countries. 

Java, Solaris and all Java-based trademarks and logos are trademarks of Sun Microsystems, Inc. in the United States and/or other countries. 

Microsoft, Windows, and Windows NT are trademarks of Microsoft Corporation in the United States and/or other countries. 

UNIX is a registered trademark of The Open Group.

Hewlett-Packard, HP and HP-UX are registered trademarks of Hewlett-Packard Company.

Other company, product, and service names may be trademarks or service marks of others.

The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law:

INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS TOOLS "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OR CONDITIONS OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you. This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the tool. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this tools at any time without notices.