When combining a C project with MFC, malloc causing problems in release mode???
Posted on 2003-02-18
I wanted to make GUI windows for a console project written that is in C. So I created a simple MFC Dialog Box Application and included all the console project's source files, header files and the library files in to the workspace and called the main(...) function of the console project on the click of a button by passing the command line arguments with it.
The actual C console project, when run in Microsoft Development Editor in both debug as well as release mode, runs perfectly.
If I run the MFC project by pressing F5 in debug mode, it runs well but causes problem when i run the debug EXE from windows explorer. It also crashes when i run it in release mode either by pressing F5, Ctrl F5 or directly run the release EXE from windows explorer.
The problem when i debugged the release mode was that at a certain point, one malloc was returning NULL despite the fact that I have enough memory (256MB) with me.
The malloc is being called from the well running C project file. The same malloc call returns good values for 6 times but returns NULL for the seventh call when i try to allocate just 13 bytes. The problem is not the memory shortage but as i think may be the linking of the C project in MFC environment.
Any help is welcomed...