|The heap corruption indicates that you have an out of bound memory write access (e.g. writing to an array beyond it's size). Running out of memory indicates that you are allocating a lot of memory but not freeing it.
For modeless dialogs follow these adviceses:
- Create a variable and initialise it (assigning
NULL or using
- When the dialog should be created the first time check if the variable is
NULL and call
new if so
- Create the dialog
- When finished with the dialog, call
- If the allocated memory is not needed anymore, delete it and assign
NULL to the variable
- When the variable goes out of scope, delete the memory (e.g. in the destructor of the class holding the variable)
I suggest to check your code for the above (each
new must have a corresponding
delete, and each
CDialog::Create must have a corresponding
Because the memory corruption is a severe error, I suggest to find the source and fix it first. Use a debug build. Then you don't need the GFlags. They are for debugging executable files where you don't have the sources.
If you know the code portions (or have a guess) where the heap corruption occurs, you can insert some AfxCheckMemory[^] calls to check the C++ heap.
A common error for such cases is forgetting to append a
Quote:it is after do the create of the dialog and populate the control including allocating via new a Richedit and streaming data to it that something goes wrong all storage is allocated via new
NULL char to the received data before passing them as string and/or forgetting to allocate the additional memory for the