Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assertion failures? 1

Status
Not open for further replies.

classic773

Programmer
Jun 14, 2001
57
US
I'm getting an assertion failure, as I previously mentioned in the 11th message of
thread116-107726
When I commented out the "delete" portions of the code, I was able to prevent this assertion failure. There was another series of "delete" statements I had to comment out in the same code for the same reason. Anybody have an ideas whats happening. MSDN hasn't been too helpful.
 
Can somebody help me figure out why I'm getting these assertion errors when I try to delete some of my pointers to dynamically declared arrays.
 
how do you create the arrays ? if it is whith something like "myArr = new myType[mySize]", then you must use
"delete[] myArr" and not "delete myArr".

If you use "calloc", then you should use "free", and so on.

 
Your allocation and deletion looks right. It runs on my machine when I compile it and do nothing to the 3 dimensional array.

If you comment out the delete statements you will have a memory leak which is not good.

How are you assigning data to the 3 dimensional array? If I were you I would step through with a debugger and check to see if you are exceeding an array boundary somewhere (e.g. writing 101 values to the array when you allocated room for 100).

I tend to get those assertion errors when I try to delete memory that I do not own, which is when I delete an object that was never allocated, or when I delete an object where I assigned a value beyond an array bound. For example, maybe I mix up Rows and Columns, trying to assign 1000 column values when I only allocated 100. The program might calculate results fine, but it will cause an assertion error on delete.

 
I found my problem: map = map_2;

obviously you can't do it like that, and must copy each array element individually.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top