HEAP[test.exe]: Invalid Address specified to RtlValidateHeap

Different problems can cause this error.

It is often related to the settings of your projects. If you use different run-time libraries for your main program and for your libraries/DLLs, they will not allocate and deallocate memory in the same way. Consequently, if some memory allocated by a library is released by another one, you may get this kind of error.
You can check your projects settings in : project->settings->C++->Code generation->Use run-time library.

However, the explanation can be really simpler. Just try to delete two times a same object, and you may get this error. To ensure that an object is not deleted twice, just put a breakpoint in its destructor.
I encountered this problem after doing a stupid mistake. I declared a CWinThread m_thread member variable in a class CMyClass I forgot that its m_bAutoDelete member variable is set to TRUE by default. Logically, m_thread was deleting itself once it was terminated. And of course, the destructor of CMyClass was trying to delete m_thread too… BOOM !!!

Leave a Reply

Your email address will not be published. Required fields are marked *