- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I have the following code:
...
idx2faclist = new int[points->items + 1];
...
delete [] idx2faclist;
...
The Intel Inspector gives me 'Mismatched allocation/deallocation' error message for the line
idx2faclist = new int[points->items + 1];
and
delete [] idx2faclist;
How to understand this error message? How to modify the code to remove this error message?
Thanks,
Zhanghong Tang
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Probably there is no adequate number of memory deallocations when compared to memory allocations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear iliyapolak,
Thank you very much for your kindly reply.
How to make sure that it is adequate number of memory to be deallocated?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You must assure that for every allocation is corresponding memory deallocation otherwise Inspector will probably complain about missing deallocation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear iliyapolak,
Thank you very much for your kindly reply.
Do you mean that there could be some allocated memory (idx2faclist ) are not deallocated, and the array is reallocated again next time? Maybe there are such problem, I will check it.
Is it better to write like this?
if(idx2faclist) delete [] idx2faclist;
idx2faclist = new int[points->items + 1];
...
delete [] idx2faclist;
Thank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After your code accessed idx2faclist array and it is not needed anymore simply use delete[] operator one time. Compiler will create code which will iterate over whole idx2faclist array and will release the memory probably by calling VirtualFreeEx on Windows.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page