Identifying memory leaks
Prerequisites:
A memory leak is an error in a program's dynamic store allocation logic that
causes it to fail to reclaim discarded memory. That is, objects that are no
longer required are not reclaimed. Unexpectedly large numbers of such instances
may suggest a memory leak. A memory leak, if severe, can lead to the collapse
of your application due to its running out of memory.
Memory leaks are caused by objects that continue to hold references to other
objects, thus preventing garbage collection from reclaiming the held objects.
The Object References table can be used to help identify such references.
Finding a memory leak in an application
To identify a memory leak in your application,...
- In Profiling and Logging perspective, select either the monitor or the agent in the Profiling Monitor view.
- Right click and select Collect Object References. Object references will now be collected.
- Right click again, and select Open With > Object Reference.
The Object References table opens.
- Select the local menu icon
and select
Show Reference To.
- Examine the list of objects and the number of references to them.
Those that have references are a potential memory leak problem.
Finding a memory leak in a transaction-oriented operation
This procedure may help identify a phase in your program that creates new objects but does not release them,
thus preventing their removal through garbage collection.
For example, your program creates a dialog window but objects
related to the dialog continue to be held after the window has been closed.
To identify a memory leak in a transaction-oriented operation,...
- In Profiling and Logging perspective, select either the monitor or the agent in the Profiling Monitor view.
- Collect object references before the operation in question.
Right click and select Collect Object References. Object references will now be collected.
- Right click on the monitor and select Open With > Object Reference.
Examine the Object References table and note the object references that were created.
- Run the operation that you want to examine.
- Collect object references after the operation has completed.
Right click and select Collect Object References again.
- Right click on the monitor and select Open With > Object Reference.
Examine the Object References table and note the object references that were created.
The objects that were created and could not be collected in the interval
between the two collection of object references will be labeled as new objects in the Object References table.
- To examine a particular object's references,...
- From the drop down menu in the Object References table, select Show Reference By.
- Select your object class, then expand the item.
- Identify the references that prevent the new objects from being reclaimed.
Related concepts
Overview of the Profiling Tool
Profiling resources
Object References table
Related tasks
Profiling an application
Launching or attaching a Java process