JRockit Memory Leak Detector User Guide

     Previous  Next    Open TOC in new window  Open Index in new window  View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Using the Memory Leak Detector

Now you understand how a flow of events for memory leak detection works and the basic functions of the user interface, it is time to get to know how powerful the Memory Leak Detector actually is in action. This part of the user guide describes the different tabs of the interface in detail and how the Memory Leak Detector works when monitoring a Java application with a real memory leak. Each tab of the interface will be explained in detail in this section.

The following topics will be covered in this section:


Analyzing the Application

From the Trend tab (see Figure 3-1), you start the analysis of your applications. The object types with the highest growth in bytes/sec are marked red (darkest) in the Trend Analysis table and they are listed at the top of the table. For each update, the list can change and the type that was the highest move down the list. The object types listed in Figure 3-1 are fetched from an example application, where you can suspect a memory leak at the objects marked red.

Figure 3-1 Memory Leak Analysis

Memory Leak Analysis

Table 3-1 explains what each column in the Trend tab displays.

Table 3-1 Trend Analysis - Which types are leaking?
Column Title
The type of object (class).
Growth (bytes/sec)
The amount of memory (in bytes) with which the type is growing, per second.
% of Heap
How much of the Java heap is occupied by this type of object, measured in percentages of the entire heap.
Size (KB)
What size in KB does that percentage correspond to.
# Instances
The number of live objects of this type that currently exist.

To Start Analyzing Your Application

To Pause Analysis of Your Application

To Stop Analysis of Your Application

To Start the Investigation

  1. Right-click the object you think contains a memory leak.
  2. Select Show Referring Types.
  3. The Types tab appears (see Figure 3-2). For instructions on how to investigate further, see To Get Closer to the Memory Leaking Object.


Investigating a Suspicious Object Type

Once you have found a suspected memory leak (a type that is high in growth and is colored red), you investigate the suspected leak further in the Types tab, see Figure 3-2. Before anything is displayed in this tab, you need to start the investigation by selecting a type from the Trend tab, see To Start the Investigation.

The Types tab offers a view of the relationships between all the types pointing to the type you are investigating. For each type you also see a number, which is the number of instances that point to that type.

Figure 3-2 Types Tab

Types Tab

The color red (dark) means that the type has a high growth rate (which may or may not be related to a memory leak).

To Get Closer to the Memory Leaking Object

  1. Double-click on the type with the darkest color.
  2. The type expands further (see Figure 3-3).

    Figure 3-3 Type Graph Expanded

    Type Graph Expanded

  3. Keep clicking the type with the darkest color red, until you get down to a “natural end” where you think you can pinpoint the memory leak.
  4. Right-click the type where you suspect a leak (see Figure 3-4).
  5. Figure 3-4 Type Graph with Memory Leak Pinpointed

    Type Graph with Memory Leak Pinpointed

  6. Select List Instances.
  7. The Instances part of the Types tab opens.

    List instances shows you instances of the selected type. The instances shown will only be those that have references to the type indicated by the arrow from the selected type in the above type graph.

    Figure 3-5 List of Instances in Types Tab

    List of Instances in Types Tab

    The lower half of the tab lists all instances of type A pointing to type B if the instance list is not too large (see Figure 3-5). If the list is too large, the Memory Leak Detector might time out when trying to display the list. You can change the time out setting under File > Preferences.

    The column Data kept alive (bytes) shows how much data a certain instance keeps alive. This data cannot be garbage collected.

    Have the Overview part of the window open to see where you are in the graph (see To Get an Overview of the Graph for how to turn on the overview). You can also zoom in/out or re-center the view (see Table 2-2 for an explanation of the zooming tools).

To Get an Overview of the Graph

To Investigate an Instance of a Type

  1. Right-click an instance in the Types tab (probably one with the highest data kept alive).
  2. Select Show Referring Instances.
  3. The Instances tab appears (see Figure 3-6).


Investigating an Object Instance

In the Instance tab, see Figure 3-6, you view the instances of the type that you suspect is leaking memory. You can also see the name of the specific field by looking at the arrow that is referring. Right-click an instance to get a popup menu with the Inspect Instance option. When inspecting an instance you will see all instance variables that the object contains. This information will help you pinpoint where in your application the leaking object is located.

Figure 3-6 Referring Instances Tab

Referring Instances Tab

Table 3-2 explains what you will be able to view in the Instances tab.

Table 3-2 Instances of Suspected Memory Leaks
Part of Tab
Instances Graph
This graph shows how the instances are connected to each other.
In the inspector view you can see all fields the object contains and their values. The information that is displayed is depending on the application you monitor.


Viewing Allocation Stack Traces

In the Allocation Stack Traces tab, see Figure 3-7, you can check for where in the code allocations of a certain type are done. Enabling allocation stack traces may deteriorate the performance of JRockit. Collecting information about all the allocation points might take a while.

Figure 3-7 Allocation Stack Traces Tab

Allocation Stack Traces Tab


Customizing Settings

The Memory Leak Detector can be customized in many different ways. Figure 3-8 through Figure 3-13 explains the different settings you can make.

To Open the Preferences Window

To Reset Preferences to Default Values

  1. Click File > Preferences.
  2. Click Defaults.
  3. Click OK.
  4. Figure 3-8 Confirm Exit Setting

    Confirm Exit Setting

Select the Confirm Exit option if you want to get a confirmation message when you are closing the Memory Leak Detector.

Figure 3-9 Display of Heap Usage

Display of Heap Usage

Here you set the ratio of the Java heap that you want displayed. Those types that are smaller than the set ratio are not displayed. If you want to display all types, set the ratio to 0 (zero).

Figure 3-10 Graph Settings

Graph Settings

Here you set the number of instances you want to list when doing List instances of a type. The list is shown in the Types tab under Instances.

Figure 3-12 Number of Array Elements that are Fetched

Number of Array Elements that are Fetched

Specify the value for the Max number of Array Elements to fetch. These elements are displayed in the Types tab when you have selected List Largest Arrays.

Figure 3-13 Timeout Setting

Timeout Setting

  Back to Top       Previous  Next