[[File:FalsePositive.png|800px]]
= Sample Code for Intel Inspector =
TBD== False Positive Code == <syntaxhighlight lang="cpp" line='line'>int main()#include <iostream>using namespace std; const int maxSize = 10; int main(){ // declaring an array of pointers int** mypointer = new int* [10]; // populating the array with pointers cout << "\n Populating Array With Pointers \n" << endl; for (int i = 0; i < maxSize; i++) { mypointer[i] = new int; *mypointer[i] = i; cout << *mypointer[i] << endl; } cout << "\n -----------------------------------------------" << endl; // Switching every even numbered pointer to be pointing towards the next odd numbered pointer cout << "\n Switching every even numbered pointer to be pointing towards the next odd numbered pointer \n" << endl; for (int i = 0; i < maxSize; i++) { if (i % 2 == 0) { mypointer[i] = mypointer[i + 1]; } } cout << "\n -----------------------------------------------" << endl; //Printing the results; cout << "\n Results of the switch \n" << endl; for (int i = 0; i < maxSize; i++) cout << *mypointer[i] << endl; cout << "\n -----------------------------------------------" << endl; // deallocating memory cout << "\n Deallocating Memory \n" << endl; for (int i = 0; i < maxSize; i++) { int check = i % 2; if (check == 0) { delete mypointer[i]; mypointer[i] = nullptr; } else { mypointer[i] = nullptr; delete mypointer[i]; mypointer[i] = nullptr; } } cout << "\n -----------------------------------------------" << endl; cout << "\n Checking nullptr's" << endl; for (int i = 0; i < maxSize; i++) { if (mypointer[i] == nullptr) cout << "pointer [" << i << "] is a nullptr" << endl; } cout << "\n **There is now a memory leak with [" << (maxSize / 2) * 4 << "] bytes of data being unreachable **" << endl; delete[] mypointer; return 0;}</syntaxhighlight>
= How to use Intel Parallel Studio Inspector =