Intel® Inspector 2013 Help
Intel® Inspector APIs, GUI tools and the inspxe-cl command tool allow you to manage memory leaks and growth detection when performing memory error analysis on your application. This topic describes your options for managing memory leak and growth detection on the command line, and describes how these commands can be used in tandem with APIs. For information on using GUI tools to manage on-demand memory leaks and growth detection, see Examining Result Data During Dynamic Analysis.
Use an API to set the start point for memory leaks and growth detection
Use an API to set points at which to detect memory leaks and growth
Use a command to reset the start point for memory leaks and growth during a running analysis
Use a command to detect memory leak and growth data during a running analysis
By default, knobs that control memory leak and growth detection are enabled by default for the mi2 and mi3 memory error analysis types. If you use one of these memory error analysis types with the default knob settings without using the APIs or the command action, memory leak and growth detection starts when analysis begins and ends when your application exits.
Prerequisite Knob Settings
The three knobs that support memory leak and growth detection are enabled in these analysis types by default: detect-leaks-on-exit, enable-on-demand-leak-detection and enable-memory-growth-detection.
Resetting the start point
When you are not interested in memory leak growth and detection at the start of the application, you can reset the starting point by issuing a command through the command line or GUI tools. This is quite imprecise unless you can issue the command at a point where the application waits for user input. For the finest control, use an API.
On demand memory leak and growth detection
If your application does not exit, or if you wish to detect memory growth and leaks at one or more points in the analysis, you can issue a command through the command line, use GUI tools or the API. The GUI allows you to issue leak-detection on demand while watching the analysis, but the API allows the most precision. You may issue multiple memory leak and growth detection commands. A detection command or API is paired with the nearest previous reset, or else defaults to the start of analysis.
Detecting memory leaks and growth in one or more intervals
You can use the API and command tool in combination, and may issue multiple reset or memory leak and growth detection commands. The intervals can overlap, in which case a detection command or API is paired with the nearest previous reset, or else defaults to the start of analysis.
Viewing memory leak and growth data
Generate a Problems report; or open the result in the GUI and view the Problems pane.
When you want to set an exact start point for memory leak and growth detection, use the __itt_heap_reset_detection (C++) or itt_heap_reset_detection (Fortran) API. For more information and an example, see APIs for Custom Memory Allocation.
If you use the API to reset the start point, you could then run the analysis from the command line and issue one or more detect memory leak and growth commands.
When you want to set exact points at which to collect memory leak and growth data, you can add the __itt_heap_record (C++) or itt_heap_record (Fortran) API. For more information and an example, see APIs for Custom Memory Allocation.
In this case, you would probably want to use the __itt_heap_reset_detection (C++) or itt_heap_reset_detection (Fortran) API to set an exact start point, as described above.
You can issue a command to reset the start point for detecting memory leaks and growth in a running mi2 or mi3 analysis. When the result is finalized, the problems will include memory leaks and growth data from this point to the end of the analysis run, to the point at which memory leaks and growth detection data was collected.
It is possible to perform this command and reset the start point more than once, in which case a new start point is established and the old start point is ignored, so this can be used if you want to replace an earlier start point.
If you use the result-dir option to specify the result directory during analysis and data collection, you must use it when issuing these commands.
After starting an mi2 or mi3 analysis on the command line, you can issue this command to reset the start point for data collection. Assuming that the result directory r000mi2was specified for the collection, the same result directory must be specified when resetting the memory leaks and growth start point.
$ inspxe-cl -command reset-leak-growth-detection -result-dir r000mi2
When you issue this command, inspxe-cl detects memory leaks and growth and collects the data. Problems in the finalized result will include memory leaks and growth data from the start point to this point in the analysis run.
If you use the result-dir option to specify the result directory during analysis and data collection, you must use it when issuing this command.
After starting an mi2 or mi3 analysis on the command line, you can issue this command to detect memory leaks and growth and collect the data. Assuming that the result directory r000mi2 was specified for the collection, the same result directory must be specified when resetting the memory leaks and growth end point.
$ inspxe-cl -command detect-leaks-growth-now -result-dir r000mi2
Supplemental documentation specific to a particular Intel Studio may be available at <install-dir>/<studio>/documentation/.