right.
Other possible causes (other than deleting the same memory twice) would include trying to delete memory that was never allocated, like
const char *AString = "abcdef";
delete [] AString;
or deleting a pointer that is not a pointer to the _start of_ a dynmically allocated block. Like
char *AString == new char [10];
for (int i = 0; i < 5; ++i)
*AString++ == 'a';
delete [] AString;
(This alters AString so it points to a character in the middle of the allocated memory, not the start, so the delete fails.)
When you get this alert, you will be inside a procedure in the C++ runtime library. i.e. not a procedure you've written. But that procedure is called (ultimately) from code you've written. you should look at the call stack (in the variables window). It lists the procedure you are currently in, the procedure that called that one, the procedure that called that one and so on until main (the bottom of the call stack). So look through the call stack until you find a procedure that you wrote. Look at that procedure, its likely the problem is there. (That procedure shoudl be calling delete, delete [] or free(). If the pointer that procedure is trying to delete with is passed to that procedure, then the problem might be in the procedure that calls it. Again you might have to move down the call stack until you reach a procedure that is really responsible for the problem.
Main Topics
Browse All Topics





by: bodokePosted on 2003-02-23 at 04:34:01ID: 8002661
It means you have a pointer/memory problem somewhere in your application. For example, if you delete a dynamically allocated block of memory twice, the second will fire the assert.
The error means you are doing something to a pointer to heap memory which is no longer valid.