Open main menu

CDOT Wiki β

Changes

GPU621/Intel Inspector

550 bytes added, 07:23, 10 August 2021
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 =
29
edits