Using the Leak Report
The Leak Report is based on the process in focus and includes two panes: at the top are the program’s files; at the bottom is the Backtrace pane. All entries in the Program pane identify memory leaks in the program. To locate the problems:
1. Drill down to identify the block in which each leak resides,
Figure 173.
Note that:
This example program has a process that contains a single file with three memory leaks (identified by the
Count column), at lines 36, 27, and 26.
The
Bytes column displays the number of bytes that have been lost to leaks.
The
Update button is grayed-out because the report is up to date. This will become active if the program continues to run past this point.
2. Select the block to analyze, which populates the Backtrace pane with the line of code where the memory was initially allocated.
The Backtrace is not the active backtrace (which is that displayed in the Call Stack view); rather, it is the backtrace that existed when your program made the heap allocation request. It identifies the block number, the function name, line number, and filename.
Selecting a different entry in the top pane refocuses the Backtrace pane.
You can also navigate directly to the source code location of the leak from the Program pane by selecting the Line entry:
3. Select the function in the Backtrace pane to highlight its location in the source code.
TotalView uses a conservative approach to finding memory leaks, searching roots from the stack, registers, and data sections of the process for references into the heap. Although leaks will not be falsely reported, some leaks may be missed. If you are within a method that has leaks, you may need to step out of the method for the leak to be reported. In addition, leak detection may be sensitive to the compiler used to build the program.
Updating the Leak Report
If you are stepping through your code or it has stopped at a breakpoint, the Leak Report view does not update automatically. At this point, the Update button becomes active, and selecting it will update the report.