Jrockit Mission Control: Oracle Jrockit Runtime Analyzer
Jrockit Mission Control: Oracle Jrockit Runtime Analyzer
Jrockit Mission Control: Oracle Jrockit Runtime Analyzer
Mission
Control ™
The Memory Leak Detector, a component of Oracle JRockit Mission Control, detects memory
leaks within Java applications running on the Oracle JRockit JVM. A memory leak means
application code is holding on to memory that is not used by the application any more. The
Memory Leak Detector is a real-time profiling tool providing information about what type of
objects are allocated, how many, of what size, and how they relate to each other. Unlike other
similar tools, there is no need to create full heap dumps that you need to analyze at a later stage.
The data presented is fetched directly from the running JVM, which can continue to run with a
relatively small overhead. When the analysis is done, the tool can be disconnected and the JVM
will run at full speed again. This makes the tool viable for use in a production environment.
The purpose of the Memory Leak Detector is to display memory leaking object types (that is,
classes) and provide help to track the source of the problem. Another purpose of this tool is to
help increase the understanding and knowledge to avoid similar programming errors in future
projects.
This help is divided into the following topics:
z Customizing Settings
Finding memory leaks in an application is a bit of a detective’s work. You might not always see
the obvious leaks. The Memory Leak Detector is a tool that can help you to locate memory leaks
in your application. Once you have found a leaking method, it is a much easier task to fix you
code.
This section describes the memory leak detection procedure that you can easily adapt to your
normal development environment, through the use of Oracle JRockit Mission Control.
This section is divided into the following topics:
z Verbose Output
When you have spotted a memory leak, you can start drilling down to the real cause of the leak
by using the Memory Leak Detector plug-in provided with JRockit Mission Control.
The topics are covered to spot a memory leak:
z Verbose Output
Verbose Output
One of the most widely used ways to monitor the activity of the garbage collector is to start the
JRockit JVM with the -Xverbose:gc option and then watch the output for a while (see
Listing 2-1).
The value after the arrow (->) is the heap usage after the garbage collection. You can clearly see
that the heap is constantly growing in the example of Listing 2-1.
Now you have determined that you have a memory leak in your system. This means that you can
start the Memory Leak Detector to figure out which object is leaking.
3. Instance Investigation
Instance Investigation
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.
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.
This section is divided into the following topics:
z Customizing Settings
1. Toolbar where you control the updating of the analysis, how to view the different graphs when
drilling down to find the memory leaks, etc.
2. Trend Analysis table that lists all types that consume memory. It lists the types in descending
order with the type that leaks the most listed at the top.
4. Tabs that indicate work flow for finding your memory leak.
Toolbar Explained
The Memory Leak Detector tool bar, see Figure 3-2, contains, for example, buttons to connect to
the JRockit JVM instance. See Table 3-1 for an explanation of the different tools in the toolbar.
Export and Print graphs. This button allows you to export the displayed graph to a jpg or gif
image.
Re-layouts the graph. This button allows you to re-layout the graph and have the selected
Restarts the graph. This button allows you to restart, i.e. expand, the node that is currently
selected.
Zooms in and out on a type or an instance. These tools help you navigate in the graph.???
Lets you view the graph in bird’s eye view. You can easily pan and re-center the graph from
this view.
Tabs Explained
The main window of the Memory Leak Detector contains four tabs as shown in Figure 3-3.
Table 3-2 explains what you can do under the different tabs.
Figure 3-3 The Tabs in the Memory Leak Detector (Indicates Work Flow)
Trend 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 (this number can be changed
in File > Preferences > Trend). The object type with the highest growth rate will be listed
first.
Types From the Types tab you view a type graph that shows how different types point to each
other.
Instances From the Instances tab you view an instance graph that shows how different instances point
to each other.
Allocation From the Allocation Stack Traces tab you view where a certain type is allocated in the
Stack Traces code.
Table 3-3 explains what each column in the Trend tab displays.
Growth The amount of memory (in bytes) with which the type is growing, per second.
(bytes/sec)
% of Heap How much of the Java heap is occupied by this type of object, measured in
percentages of the entire heap.
# Instances The number of live objects of this type that currently exist.
Analysis Procedures
This section contains the procedures you can use analyze your application. It shows you how:
The color red (dark) means that the type has a high growth rate (which may or may not be related
to a memory leak).
2. 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.
The lower half of the tab lists all instances of type A pointing to type B if the instance list
is not too large. 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 Window >
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.
Table 3-4 explains what you will be able to view in the Instances tab.
Instances Graph This graph shows how the instances are connected to each other.
Inspector 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.
2. Select Open Method or Open Type (depending upon what you are jumping from).
Customizing Settings
You can change preferences for time-outs, communication ports, updating frequency, etc. for the
Memory Leak Detector.
3. Click OK.
2. Select one of the communication options for the Memory Leak Protocol (MLP)
communication.
– Let OS choose—this is a convenient choice if you are not sitting behind a firewall.
– Use fixed port—this is used when you are running one JRockit JVM behind a firewall.
– Use port relative to JMX port—this is used when you are running several JVMs on
the same computer and the computer is behind a firewall. You decide how many
increments (a number between 1 and 65535) you want the TCP port for the MLP
communication to be.
3. Click OK.
– Animate layouts, when selected, animates the expansion of a node on the type in
Types tab and the Instances tab.
– Automatically center the last expanded node, when selected, centers a type in the
viewing area for the Types tab and Instances tab.
– Number of referred nodes to add when a node is expanded, when set, controls how
many nodes you want to be displayed in the Types tab and Instances tab. If you
specify a very high number, the view can become cluttered.
– Show fully qualified class names in graph nodes, when selected, displays the
complete class name in the graphs of the Types tab and Instances tab.
2. Click OK.
2. Click OK.
2. Click OK.