In a continuously running application, the following procedure enables memory leak
detection at any particular point during program execution:
-
Find a location in the code where you want to check for memory leaks, and
insert a breakpoint.
-
Launch the application in Debug mode with the Memory Analysis tool
enabled.
-
Change to the Memory Analysis perspective.
-
Open the Debug view so it is available in the current perspective.
-
When the application encounters the breakpoint you specified, open the Memory
Analysis session from the Session View (by double-clicking) and select the
Setting page for the Session Viewer.
-
Click the Get Leaks button.
Before you resume the process, take note that no new data will be
available in the Session Viewer because the memory analysis thread and
application threads are stopped while the process is suspended by the debugger.
-
Click Resume in the Debug view to resume the process'
threads.
If leaks did not appear on the Memory Problems tab of the Session Viewer, either
there were no leaks, or the time given to the control thread (a special memory
analysis thread that processes dynamic requests) to collect the leaks was not
long enough to perform the command; and was suspended before the operation
completed.
-
Switch to the Errors page of the viewer, to review information about collected
memory leaks.
Note: Besides apparent memory leaks, an application can have other types of leaks that
the memory Analysis tool cannot detect. These leaks include objects with cyclic
references, accidental point matches, and left-over heap references (which can be
converted to apparent leaks by nullifying objects that refer to the heap). If you
continue to see the heap grow after eliminating apparent leaks, you should manually
inspect some of the allocations. You can do this after the program terminates
(completes), or you can stop the program and inspect the current heap state at any
time using the debugger.