Skip navigation.
Downloads | Product Documentation | Support

Using the JRockit Memory Leak Detector

# Getting Started with Memory Leak Detection

This section describes the BEA JRockit Memory Leak Detector (from now on referred to as Memory Leak Detector) start-up procedure and the user interface. Information on the following topics are included:

- Overview of the Memory Leak Detection Process
- Starting the Memory Leak Detector
- Touring the Memory Leak Detector Interface

# Overview of the Memory Leak Detection Process

The memory leak detection process consists of three phases:

1. Trend analysis
2. Object type relations study
3. Instance investigation

Trend analysis means to observe continuously updated object type related information and try to discover object types with suspicious memory growth. These object types should then be studied in the next phase of the memory leak detection process. The information in the trend analysis table is updated every ten seconds or more often if there are very frequent garbage collections.

Studying object type relations means repeatedly following reference paths between object types. The goal is to find interesting connections between growing object types and what types of objects point to them. Finding the object type guilty of unusual memory growth will lead to the third and final phase of the memory leak detection process.

Instance investigation consists of finding an instance of abnormal memory size or an abnormal amount of references being held and then inspecting that instance. When inspecting an instance, values will be displayed; e.g. field names, field types, and field values. These values will hopefully lead you to the correct place for the error in the application code; i.e. where that particular instance of that particular object type is allocated, modified, or removed from the collection, depending upon what the situation implies. Minimizing the problem areas of the ones connected to the suspected instance will most likely lead you on the right track to finding the actual problem causing the memory leak and you will be able to fix it.

# Starting the Memory Leak Detector

Before you start the Memory Leak Detector and your application, you need to start the management server.

1. Start your Java application with the BEA JRockit JVM as usual, but add the `-Xmanagement` option to the command line.
2. Start the Memory Leak Detector by typing `java -jar MemoryLeakDetector.jar` in a command window.
3. Enter a name for the server in Server name. This is the name (or IP address) of the computer that runs JRockit and the application that you want to monitor.

The default port is 7091. For changing the port of the management server, see Changing the Port in Using the BEA JRockit Management Console at:

>     http://edocs.bea.com/wljrockit/docs50/usingJMC/start.html#1036322

4. Click Connect in the Connect to JRockit window.

The Memory Leak Detector window opens (see Figure 2-1).

# Touring the Memory Leak Detector Interface

When it is not connected to any BEA JRockit JVM, the Memory Leak Detector window looks like Figure 2-1. The interface consists of four tabs, a tool bar, main menus, and a status bar.

Figure 2-1 The Main Window of the Memory Leak Detector

## Tabs Explained

The main window of the Memory Leak Detector contains four tabs as shown in Figure 2-2: Trend, Types, Instances, and Allocation Stack Traces.

Figure 2-2 The Tabs in the Memory Leak Detector (Indicates Work Flow)

Table 2-1 Tabs Explained

Tab | Description
--- | ---
| From the Trend tab you view a trend analysis of the object types on the Java heap. You will see a list of all types that occupy more than 0.1% of the heap. The object type with the highest growth rate will be listed first.
| From the Types tab you view a type graph that shows how different types point to each other.
| From the Instances tab you view an instance graph that shows how different instances point to each other.
| From the Allocation Stack Traces tab you view where a certain type is allocated in the code.

## Toolbar Explained

The Memory Leak Detector tool bar, see Figure 2-3, contains, for example, buttons to connect to the JRockit instance. See Table 2-2 for an explanation of the different tools in the tool bar.

Figure 2-3 The Toolbar in the Memory Leak Detector

Table 2-2 Toolbar Explained

Icon | Description
--- | ---
| Connect to the management server. This button connects you to the management server, which in turn allows you to monitor your Java application.
| Disconnect from the management server and your Java application.
| Start monitoring your Java application.
| Pause the screen updating.
| Stop the current monitoring.
| Refresh the current view.
| Zoom in on a type or an instance. This tool helps you navigate in the graph.
| Zoom out from a type or an instance.
| Center objects in your viewing area.

## Status Bar Explained

The status bar (Figure 2-4) at the bottom of the window displays information regarding the current connection, whether the trend analysis is on or not, and whether the allocation stack trace is on or not.

Figure 2-4 The Status bar in the Memory Leak Detector