Difference between revisions of "GPU621/Intel Inspector"
(→Memory Leak) |
|||
Line 38: | Line 38: | ||
= Memory Leak = | = Memory Leak = | ||
+ | |||
+ | <syntaxhighlight lang="cpp" line='line'> | ||
+ | int main() | ||
+ | { | ||
+ | int* myInts = new int[5] ; | ||
+ | |||
+ | // incorrectly deallocating an array of pointer | ||
+ | delete myInts ; | ||
+ | |||
+ | return 0 ; | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | The result shows there is memory allocation on line 5 and it is causing memory leak. | ||
+ | |||
+ | [[File:memoryLeak_notFreed.png|1200px]] | ||
+ | |||
+ | |||
+ | If there is type mismatched deallocation, Inspector will mark down the allocation and deallocation line. | ||
+ | |||
+ | [[File:memoryLeak_mismatched.png|1200px]] | ||
+ | |||
+ | In this case, the correct way to deallocate an array of pointer is delete[] myInts. | ||
= References = | = References = |
Revision as of 07:23, 10 August 2021
GPU621/DPS921 | Participants | Groups and Projects | Resources | Glossary
Contents
Intel Parallel Studio Inspector
Project Overview
Intel Inspector is a dynamic memory and threading error debugger which able to detect and locate memory leaks, deadlocks, and race conditions. The purpose of this project is to introduce Intel Inspector and demonstrate how to use Inspector to debug our code.
Group Members
Features
The purpose of the Intel inspector is to help us find difficult and non-deterministic errors in large programs. As the program gets bigger and has complicated logic it is difficult to find memory leaks and threading errors. Some of it's main features are
- Locate Nondeterministic Threading Errors
- Detect Hard-to-Find Memory Errors
- Simplify the Diagnosis of Difficult Errors
- Find Persistence Memory Errors
Software supported
Intel Inspector supports various languages (C, C++, and Fortran), operating systems (Windows and Linux), IDEs (Visual Studio, Eclipse, etc.), and compilers (Intel C++, Intel Fortran, Visual C++, GCC, etc.). It also supports OpenMP, TBB, Parallel language extensions for the Intel C++ Compiler, Microsoft PPL, Win32 and POSIX threads, Intel MPI Library.
Tutorial
Intel Inspector GUI
We will analyze a simple code with memory leak to demonstrate the steps to use Intel Inspector's Analysis
Step 1: Write your code which is to be analyzed and build the project
Step 2: Go to tools > Intel Inspector > Memory Error Analysis (there are several other options which can be used as per requirements)
Memory Leak
int main()
{
int* myInts = new int[5] ;
// incorrectly deallocating an array of pointer
delete myInts ;
return 0 ;
}
The result shows there is memory allocation on line 5 and it is causing memory leak.
If there is type mismatched deallocation, Inspector will mark down the allocation and deallocation line.
In this case, the correct way to deallocate an array of pointer is delete[] myInts.