Finding Memory Leaks On Demand
Intel Inspector
distinguishes among
Memory leak
,
Memory not deallocated
, and
Memory growth
problem types in the following manner:
- Memory leakproblems occur when a block of memory is allocated, never deallocated, and not reachable (there is no pointer available to deallocate the block). Severity level =
(
Error). - Memory not deallocatedproblems occur when a block of memory is allocated, never deallocated, but still reachable at application exit (there is a pointer available to deallocate the block). Severity level =
(
Warning). - Memory growthproblems occur when a block of memory is allocated, but not deallocated, within a specific time segment during application execution. Severity level =
(
Warning).
Intel Inspector
customarily displays memory leaks at the end of an analysis run when an application exits; however, you can also use the
Intel Inspector
on-demand memory leak detection feature to gather memory leak information while an application is running. This is useful if:
- An application does not terminate (such as a server process).
- You want memory leak information, but you do not want to wait for an application to terminate.
- You want to determine if memory is leaked during a specific interval of application execution, or during a specific user action.
- You want to discard information about allocations performed during initialization as a way of filtering out allocations that are not currently of interest.
To find memory leaks on demand:
Prerequisites:
- Select theEnable on-demand leak detectioncheckbox when configuring a memory error analysis.
- Run the memory error analysis.
Steps:
- If desired, click theReset Leak Trackingbutton on theCommandtoolbar to mark the start point of the time period during which you want to find memory leaks. (The default start point is the application start.)When you click this button, theIntel Inspectordiscards earlier allocation data and tracks leaks only in new allocations. Any new memory leaks on memory allocated prior to the button click do not appear in the result.
- When desired, click theFind Leaksbutton to find memory leaks in the current allocation set.Outcome: TheIntel Inspectorgenerates aMemory leakproblem in theSummarywindow for any memory leak detected during the time period.
- Do one or more of the following:To Do ThisDo ThisReview the detected memory leaks.Click theSummarybutton to check forMemory leakproblems.Continue finding memory leaks in the current allocation set.Repeat step 2.Discard earlier allocation data and search for memory leaks only in new allocations.Repeat steps 1 and 2.
- When you are finished, exit the application to end analysis, or simply let the analysis finish.Outcome: TheIntel Inspectorfinalizes and displays the result.
For more precision, consider using the GUI-based on-demand memory leak
detection commands in tandem with APIs for custom memory allocation.