Heap Status Source Report
The Source report (the top screen in
Figure 63) contains three scrolling areas as well as a top control area. The area
Data Source specifies the information to display: allocations, deallocations, or the hoard. In most cases, you’ll want to see allocations. You cannot combine these kinds of information into one report.
By default, MemoryScape does not show leaks. To see them, select the
Detect Leaks check box. If you have created a filter, apply it to the display by using the
Enable Filtering check box. (For information on filtering, see
Task 10: “Filtering Reports”.)
The top area organizes information by your program’s source files. The Bytes column contains the amount of memory associated with a line in each file. Sorting on the Bytes column while displaying leaks helps to focus on those that waste the most memory; why focus on a leak that is under 1K when there’s a 10M leak?
By repeatedly clicking, you’ll soon get to the line in your program from which memory was allocated. The information here shows each block allocated from this line and the backtrace ID associated with it.
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.
As you click on lines in the top portion, the bottom right area shows lines from your source code. The line mentioned in the top area is highlighted here,
Figure 64.
When you need to see the backtrace, just click on the backtrace ID at the bottom left. As you select different levels in the stack in the backtrace, the display in the source area changes.