In my iPhone application (XCode 3.2.4, iOS3.1.3), if I run the application in RELEASE mode, all is fine, but in DEBUG mode, the application crashes with an EXC_BAD_ACCESS exception. The application does some complex calculations. All the main code is contained in several C++ static libraries and the UIApplication only creates an object from one of these libraries and calls a method of this object.
If I put into a secondary thread the code which calls the complex calculations, I still have the same behavior: EXC_BAD_ACCESS exception in DEBUG mode and no problem in RELEASE mode.
Then I've looked around the thread stack size. By default, iOS set a thread stack size with 512 Kbytes for secondary threads and 1024 Kbytes for the main thread. I've looked the minimal required value for the thread stack size to run correctly my application. I've found the following result: 40 Kbytes for the RELEASE version. 1168 Kbytes for the DEBUG version.
The value 1168 Kbytes in DEBUG version explains why in the main thread, the application will crash (defaut stack size for the main thread is 1024 Kbytes).
I really don't understand why the required thread stack size is so different between the RELEASE and DEBUG version of my application (40 KB vs 1168 Kb !!!). I would like any help to understand this issue.
Thank you. Marc