Using the Heap Report
Similar to the Leak Report, the Heap 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 allocations in the program. To locate the allocations:
1. Drill down to identify the block in which each memory allocation resides,
Figure 143.
Note that:
This example program has a process that contains three separately-allocated memory blocks (identified by the
Count column), two allocated by the program at lines 27 and 26.
The report is based on
p1, or Process 1. If this program had multiple processes, focusing on another process would generate a separate Heap Report.
The
Bytes column displays the number of bytes of allocated memory, rounded.
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, and focuses on the relevant line of code in the source pane:
Like the Leak Report, you can navigate from both the Backtrace pane and the program pane to the relevant line in the source pane.
The Memory Report backtrace reflects the backtrace that existed when your program made the heap allocation request. The backtrace ID helps associate each block of code allocated from this line.
There is a distinction between backtraces associated with the statement and the statement in your program that allocates memory. Suppose you have a function called create_list(). This function could be called from many different places in your code, and each location will have a separate backtrace. For example, if create_list() is called from eight different places and each was called five times, there would be eight different backtraces (and eight different backtrace IDs) associated with it. Each individual backtrace would have five items associated with it.
Updating the Heap Report
If you are stepping through your code or it has stopped at a breakpoint, the Heap Report view does not update automatically. At this point, the Update button becomes active, and selecting it will update the report.