Skip to main content
gamedev.net
🔒 Locked

Difference between Debug and Release code...

Started by seejenn Apr 19, 2006 at 3:19 AM 11 replies 2.1k views
Original Post
seejenn
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.
moeron
moeron
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.
moe.ron
dawidjoubert
dawidjoubert
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..
----------------------------http://djoubert.co.uk
seejenn
seejenn
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.
Sneftel
Sneftel
Use a profiler and find out what's sucking up all your time in Release mode.
seejenn
seejenn
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.
EonStrife
EonStrife
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
xEricx
xEricx
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.
EonStrife
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...
JBourrie
JBourrie
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++;
MaulingMonkey
MaulingMonkey
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 ;-).
EonStrife
EonStrife
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) ?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.