Assert

Started by
12 comments, last by VladR 18 years ago
There's _CrtDumpMemoryLeaks, but this isn't caused by memory leaks. Memory leaks won't cause your program to crash (unless it's from failing to allocate memory).

Also bare in mind that _CrtDumpMemoryLeaks will show all unalocated memory including STL allocations that will usualyl be freed when the application exits.
Advertisement
I think Evil Steve is right here. There may be a buffer overflow before the delete, wich overwrite the internal structure of the heap. When the CRT try to free the allocated memory, it detect the corruption and cause the error. I remember there is an option in VC++2005 to detect buffer overflows at runtime, but I don't know if it works for arrays created with new.
Texture->Path = new WCHAR[PathLength]...if(Texture->Path != NULL){//At his point Texture->Path is 0x003c55e8delete[] Texture->Path; //Here comes the error message//At his point the adress is NOT 0xfeeefeee or NULL, it's again 0x003c55e8Texture->Path = NULL;}


Step 1: Remove the "..." code.

What happens with:
Texture->Path = new WCHAR[PathLength];if (Texture->Path != NULL) {  delete[] (Texture->Path);  Texture->Path = NULL;}

Also, to check the adresses, make sure you are setting the pointers at startup to NULL. This is best accomplished by constructor - thus any object created shall have the pointer set to null. Then, trace the program step by step to see when the adress changes (or just try releasing it every few lines until it crashes again to spot the place which is the origin of bug), because something overwrites it. Only you can debug it. It`s a slow and painful process, but it can be done only by you.

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

This topic is closed to new replies.

Advertisement