Memory Analysis Editor

View memory analysis data

Description:

When you view a connected memory analysis session, the Memory Analysis perspective opens that session in the main editor area of the IDE:

Memory Analysis editor

The top half of the window shows details for the data selected in the bottom half, which is an overview of the entire memory analysis session data set:

Details of selected allocations

The details include a table of information about the allocations. If you select an allocation, a vertical line indicates its position in the Details chart, and the backtrace (if available) is displayed below the table. If you click on a backtrace, the editor displays the associated source code (if available) in another tab.

The icons in the table indicate the type of allocation or deallocation:

Matched allocation
An allocation with a matching deallocation.
Matched deallocation
A deallocation with a matching allocation.
Unmatched allocation
An allocation without a matching deallocation.
Unmatched deallocation
A deallocation without a matching allocation.

The Allocations Overview can be very wide, so it could be broken into pages. You can use the Page field to move from one page to another, and you can specify the number of points to display on each page.


Note: If the process does many allocations and deallocations, it could take some time for the traces and events to be registered, indexed, and displayed.

The tabs at the bottom let you switch between several different data views:

Selecting data

To select data in the overview: Click and drag over the region you're interested in.

The Memory Analysis perspective updates the details to reflect the data region you've selected.

Controlling the view

The Memory Analysis editor has several icons that you can use to control the view:

Use this icon: To:
[Horizontal layout] Set the Chart and Detail Pane to a horizontal layout, one beside the other
[Vertical layout] Set the Chart and Detail Pane to a vertical layout, one above the other
[Restore] Display the Detail Pane if it's currently hidden
[Chart] Hide the Detail Pane so the Chart pane has more display room
[Detail Pane] Hide the Chart pane so the Detail Pane has more display room
[Toggle Chart Overview] Toggle the Overview pane on and off

Controlling the overview

You can control the Overview pane through its context menu, which is displayed when you right-click on the Overview pane:

Overview pane's context menu

This menu includes:

By Timestamp
Display the events sorted by their timestamp. Because several memory events can occur with the same time stamp, this might present the events in a confusing order (for example, a buffer's allocation and deallocation events could be shown in the wrong order if they happen during the sampling interval).
By Count
Display events sorted by their event index. This is the default ordering in the Overview pane.
Filters...
Filter the displayed events by size, type, or both. You can also hide the matching allocations and deallocations, so that you see only the unmatched ones.

Memory Analysis Filters

Zoom In
Zoom in on the selected range of events.
Zoom Out
Zoom out to the set of memory events that you previously zoomed in on.

Controlling the detail pane

You can control the Detail pane through its context menu:

  1. Right-click on the Detail pane.
  2. Choose a graph from the Chart Types menu:

Allocations tab

As described above, the Allocations pane shows you allocation and deallocation events over time. Select a range of events to display a chart and details for those events.

Errors tab

The Errors pane shows any memory errors (in red) or leaks (in blue) detected while collecting statistics. Select a line in the top pane to see a function backtrace in the lower pane.

Errors

Bins tab

The allocator keeps counters for allocations of various sizes to help gather statistics about how your application is using memory. Blocks up to each power of two (2, 4, 8, 16, etc. up to 4096) and "large" blocks (anything over 4 KB) are tracked by these counters.

The Bins pane shows the values for these counters over time:

Bins

You can disable a counter's display by clicking its circle above the pane's title. Click the circle again to enable that counter's display.

When the Bins pane is displayed, the Chart pane shows allocations and deallocations for each bin at the time selected in the Detail pane. The Detail pane lists memory events for the selected region of the Bins pane.

The Bins pane includes these additional buttons:

Play icon
Plays the selected range of the Use Bins; the Bins Statistics chart displays the usage dynamically.
Play icon
Stops the playing.

Tracing can be slow, and it may also change the timing of the application, because of the logging that's done for each allocation and deallocation. You might want to do a first pass with the bins snapshots enabled to determine the "hot spots or ranges", and on the second pass reduce the tracing to a certain range (minimum, maximum) to filter and reduce the log set.

Bands tab

For efficiency, the QNX allocator preallocates "bands" of memory (small buffers) for satisfying requests for small allocations. This saves you a trip through the kernel's memory manager for small blocks, improving your performance.

The bands handle allocations of up to 16, 24, 32, 48, 64, 80, 96, and 128 bytes in size, and activity in these bands is shown on the Bands pane:

Bands

Usage tab

The Usage pane shows your application's overall memory usage over time.

Usage

Trace Details tab

This tab plays back the allocations, synchronized with the bins, bands, or usage, depending on what you last selected. You can use this display to look for memory leaks (e.g. bins where the number of allocations is much greater than the number of deallocations):

Trace details

Statistics tab

The Statistics pane gives you several different statistics views for the Memory Analysis session.

The Allocations pane shows the number of calls to different kinds of allocations, plus a count of each allocation for a given number of bytes:

Statistics - Allocations

The Backtraces pane shows you a list of memory event points in your application. Select one to display a function backtrace for that event:

Statistics - Backtraces

The Outstanding traces pane shows allocations that weren't deallocated when the trace ended. These aren't necessarily errors.

Statistics - Outstanding traces

The Errors pane shows you a list of the different types of memory error encountered while running your application.

Statistics - Errors

Settings tab

This tab lets you change the settings for a running process.

Settings

For information about the settings, see "Analyzing your program" in the Finding Memory Errors chapter.

The additional icons (from left to right) let you: