Game Development Community

Debug Vs Release Builds

by Gregory Stewart · in Torque Game Builder · 09/06/2005 (7:14 pm) · 6 replies

It's me again. Ok, so I understand the difference between Debug and Release builds from programming in C++ for quite some time. However, I just compiled the engine in Release mode to find out, to my horror, that my program did not run the same! In Debug mode, my character jumps into the air and falls back down perfectly. Now, in Release mode, my character goes up into the air and doesn't really come back down (ok, occasionaly he will.. but not consistently or predicatably).

The only changes I've made to the C++ source is changing GL_LINEAR filtering to GL_NEAREST, and applied the mouse bug fix as describe in another thread. Switching to Release mode should not affect my code this much.

Does anybody have any idea as to why my game would be behaving differently in these two builds? I have not written any code that depends on DEBUG vs RELEASE. Does T2D Release mode have different timing or order of execution for events? Just wondering if anybody had any idea on this before I dive in and spend hours trying to figure this out.

I'd appreciate any help on this. Thanks guys!

- Greg

#1
09/06/2005 (7:16 pm)
Simple answer: "Debug build contains debug symbols and can be debugged while Release build doesn't contain debug symbols and cannot be debugged. Hence Release build will perform faster compared to a Debug build binary."

Google rocks :p
#2
09/06/2005 (7:19 pm)
Gregory- it sounds like you have also made C++ code changes in addition to changing from debug to release. Maybe you should test those changes in debug mode just to be sure.
Also, anything showing up in the torque console?
#3
09/07/2005 (4:49 pm)
Alright, I suppose I'm going to have to dive into this one. Here's the problem: the Release build seems slower than the Debug version because it doesn't seem to check the player position as often (this is just a guess... I'm not positive on it).

In any case, I will investigate this and post here when I find the solution, just in case it helps someone else.
#4
09/07/2005 (5:15 pm)
FYI, in c++ there is a very very real difference in DEBUG vs RELEASE builds.

debug builds use different libraries, and memory is managed differently.

a huge example on this is some of the memory management functions. i dont remember which one, (it might be 'new') but one of the alloc functions that is supposed to allocate on the stack actually allocates on the heap in debug builds, which is useful for debug purposes. (also i think deletes dont really take effect the same way)

i read this by reading the memory allocation function docs via MSDN. they go into the differences between C++ functions between builds.

also, floating point can be different.

to help you troubleshoot the problem:
If you use visual studio, you should try deleting the "release" settings and copy them from debug. Then, one-by-one go through and tweak the release build settings until you find out what the culprit was.
#5
09/07/2005 (6:12 pm)
Ok, so I have figured out that it is a floating point issue. Thank you Jason for your help. For some reason, the floating point is either more accurate or less accurate in Release mode versus Debug mode.

Here's what I was doing.. I was using setConstantForce() to simulate gravity. Every time my player jumped, I set the linear velocity to -120. Now, in Debug mode, apparently the linear Y velocity was never equal to exactly 0, but in Release mode, it was.

So, to fix this problem I just changed my script code so that in a function that gets called every frame, I check to see if the Y velocity is equal to 0. If it is, I set it to 1.

So, it sounds like this was a floating point precision difference between Debug and Release. Somebody correct me if I'm wrong. =)

Thanks again for all of your help, everybody.
#6
09/07/2005 (8:34 pm)
Wow, i actually helped someone fix a *real* problem.. i'm moving up in this world (errr. fourm)