I have created a program that seems to work fine and prints the right results while in debug mode. The problem is that when i try to run it without debugging it stops and doesn’t respond. The same thing happens if i run the executable file directly from the debug folder. I have added some print statements at specific points of my code to try and find where the program really stops working. It seems that it stops in a subroutine which includes many DO loops and some IF statements. What is the most possible reason which may cause this problem? Did any of you had a similar experience?
It is hard to tell without seeing it. I would try to compile with -O0 -g first. Then check where the loop that it exists or stops running , which iteration. When you say it stops, I assume it exits the program, not running infinitely loop. If this is on windows, check if there are too many recursive calls within a loop. If yes, you will need to reserve stack at link time.
Thank you very much for helping me. Actually this seems to be the problem. This is a computational mechanics program. When i run small problems there is no problem. But when I try to run one that needs large memory allocations it stops in that subroutine. It involves many loops which communicate with each other and that is where the program has the problem. I suppose that the way the compiler behaves is different in ‘‘debug’’ and ‘‘without debugging’’ case. How do I reserve stack memory at link time? I appreciate every little hint since I’m not very experienced and I am working with PVF for 10 days only. I was using another compiler in the past which was where I Have developed the code. Do different compilers use different settings for the stack?
P.S : When I say it stops it actually stops the loop somewhere (I print the loop index to see where it stops) and then it doesn’t respond.
How do I reserve stack memory at link time?
The flag “-stack=” sets the stack’s reserve size. You can add this flag to your project Property page’s Link settings under the ‘Command Line’ options.
Do different compilers use different settings for the stack?
The stack size is set by MS Link, so it’s more a matter of how the compiler passes the flag to the linker. Unfortunately, I don’t know specifically how other compilers pass this flag to Link, but would assume that it’s similar.
Hope this helps,
The problem is now solved!!! Actually there was an integer array which was not initialized to 0 and the values which contained were wrong when I was running without debugging. Thank you for the support and your help!!!