• Advertisement
Sign in to follow this  

Difference between Debug and Release code...

This topic is 4319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Gamedev, Earlier, there was a thread that discussed the difference between running in debug and release mode. From what I understood from the thread, it's expected that running in release mode would be much faster than running in debug mode. But I'm experiencing the opposite. My code compiled in debug mode is running much faster than the one compiled in release mode. Would you know what could be causing this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Could you provide any more information, or perhaps the code that you have profiled and seen to be faster in debug? How exactly are you profiling the code too? It is a bit odd to have your code performing better in debug than release builds, but it could be many things.

Share this post


Link to post
Share on other sites
Quote:
Original post by seejenn
Hi Gamedev,

Earlier, there was a thread that discussed the difference between running in debug and release mode. From what I understood from the thread, it's expected that running in release mode would be much faster than running in debug mode. But I'm experiencing the opposite. My code compiled in debug mode is running much faster than the one compiled in release mode. Would you know what could be causing this?

Thanks.


One quick thing to remember for debug vs release.

In release mode all asserts are dropped, which means the followign code will work in debug but not releae:
assert(pointer++)

There is a way around this, a simple way i just dont remember..

Share this post


Link to post
Share on other sites
All my code does is retrieve data from the database and format everything into an output flat file. I can't post the code here as I'll be breaking company policy but it's just a simple retrieve-format-output process. I'm not sure why it's running longer in release mode than in debug mode. i'm not even sure if i have to rewrite the whole thing. That sucks.

Share this post


Link to post
Share on other sites
Use a profiler and find out what's sucking up all your time in Release mode.

Share this post


Link to post
Share on other sites
I noticed that the release mode run is not eating up as much of the CPU as the debug mode run. Is this expected? Or is this what's causing it to run slower? I don't know how to run the profiler against my code. Need help.

Share this post


Link to post
Share on other sites
Oh, yeah...
I wonder, my program never crash (throws exception) in debug mode. But, when I change it to Release code, it always crashes ! What should I do ?
BTW, I use VC++ 6.0 SP6

Share this post


Link to post
Share on other sites
EonStrife, its probably uninitialized variables, your debugger fills them with values when running in debug, but in release, if you don't initialize them, they contain whatever might have been at this place in memory before it got instanciated.

Share this post


Link to post
Share on other sites
xErix, thanks. But, I think that VC++ won't compile (or generate error messages) if I use uninitialized variables...Hence, I won't be able to run the program in debug mode if I do that...

Share this post


Link to post
Share on other sites
Quote:

In release mode all asserts are dropped, which means the followign code will work in debug but not releae:
assert(pointer++)

There is a way around this, a simple way i just dont remember..


I'd say the easiest way around it is to not write asserts that affect the code:

assert(pointer);
pointer++;

Share this post


Link to post
Share on other sites
Quote:
Original post by EonStrife
xErix, thanks. But, I think that VC++ won't compile (or generate error messages) if I use uninitialized variables...Hence, I won't be able to run the program in debug mode if I do that...


It may generate a warning if it can tell, which is a big "if". You may also need to crank up the warning settings to get it to display, I don't remember VC's default behavior on this off the top of my head. Try it anyways, it might uncover the problem ;-).

Share this post


Link to post
Share on other sites
Uninitialized variable....Like this one ?

int i;

Then I should do this ?

int i=0;

??

BTW, a little OT. Seems that I have hidden breakpoints in my program (I use VC++ 6.0). Sometimes, the program breaks and VC++ gives message like "User Breakpoint at xxxxxxxx), and I am presented with assembly code. How do I clear those hidden breakpoints (Even though the breakpoint list in Edit->Breakpoints is empty) ?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
User breakpoint = exception, so fix your faulty code to remove them ;)
And dont use vc++ 6, download the express version of vc++ 8.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement