Odd Debug Assertion Error with Delete
Ok, I''m getting a debug assertion error when I use the delete operator on a dynamically allocated array of a class. Normally I''d be able to handle this. However, the problem is, it only happens every about 1 out of 4 times I run the program. I''ve looked through my code, and can''t find anything wrong. I''m not looking for help with my code, just ideas as to what might be causing this weird behavior. Thanx.
-------------------------------NeXe: NeHe DirectX-style. Follow the orange rabbit.
Since it doesn''t always happen, try to find events in the program unique to the times that it does give the error.
E.g. if its a game, and you get killed by a particular enemy and you get the assertion error, but when you don''t get killed by that enemy there''s no assertion error, then you would want to look at the related code.
Basically be a detective. Look for clues that lead to the assertion error.
Unfortunately these types of things are the hardest to find, especially on programs that are big and complex.
Good luck.
I guess this is where most people put a famous quote...
"Everything is funnier with monkey''s" - Unknown
E.g. if its a game, and you get killed by a particular enemy and you get the assertion error, but when you don''t get killed by that enemy there''s no assertion error, then you would want to look at the related code.
Basically be a detective. Look for clues that lead to the assertion error.
Unfortunately these types of things are the hardest to find, especially on programs that are big and complex.
Good luck.
I guess this is where most people put a famous quote...
"Everything is funnier with monkey''s" - Unknown
--------------------------I guess this is where most people put a famous quote..."Everything is funnier with monkey''s" - Unknown
Perhaps you are doing a double delete? If two areas of code are sharing the same memory, and one is deleted, and then another area of code decides to free it up, you may get an assertion error for a double deallocation....
CodeMonkey
CodeMonkey
CODE Monkey
It''s happenning in my exiting code, so, no special conditions to be happening there. I''ll take a look for what you suggested, codemonkey.
-------------------------------NeXe: NeHe DirectX-style. Follow the orange rabbit.
Yep, I was deleting it twice, in the most elaborate of elaborate ways.
What I had, was, in my main message loop, it checked to see if there was a message in the message que, and if it was WM_QUIT, it broke from the loop. My shutdown function posted a WM_QUIT message after releasing all the game objects. However, I was only checking once to see if there was a message. Every once in a while, there''d be multiple messages in the que before I posted WM_QUIT. So, it wouldn''t retrieve it till a couple more times through the loop. This caused it to call the release function again, which tried to delete stuff I had already deleted. So, I fixed it my changing my if (PeekMessage.. to while (PeekMessage..
Thanx for everyone''s help, especially codemonkey, I never would''ve found this without you.
What I had, was, in my main message loop, it checked to see if there was a message in the message que, and if it was WM_QUIT, it broke from the loop. My shutdown function posted a WM_QUIT message after releasing all the game objects. However, I was only checking once to see if there was a message. Every once in a while, there''d be multiple messages in the que before I posted WM_QUIT. So, it wouldn''t retrieve it till a couple more times through the loop. This caused it to call the release function again, which tried to delete stuff I had already deleted. So, I fixed it my changing my if (PeekMessage.. to while (PeekMessage..
Thanx for everyone''s help, especially codemonkey, I never would''ve found this without you.
-------------------------------NeXe: NeHe DirectX-style. Follow the orange rabbit.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement