Jump to content
  • Advertisement
Sign in to follow this  
Uphoreum

Difference Between Debug and Release Mode?

This topic is 3767 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

I'm using Code::Blocks/MinGW. After switching to release mode to compile, I noticed a bug while testing the release executable. Since I can't place breakpoints in release mode, it makes it difficult to debug, so I switched back to debug mode expecting the same results. The problem is, I can't seem to reproduce the bug in debug mode. So, my question is, is there something different about how the debug and release executables are run that would cause something to happen in the release executable but not the debug one? If so, what kinds of things should I be looking for? I'd post code, but it's a giant mess and I'm hoping there is just something that I don't know about release executables.

Share this post


Link to post
Share on other sites
Advertisement
The most common release only bugs I've seen are caused by uninitialized variables. In debug variables will commonly be initialized to 0 for you, whereas in release mode they can contain anything, which can cause problems.

Share this post


Link to post
Share on other sites
Take this with a grain of salt but it should help. :) In Debug mode you get symbols, optimizations are not included (I think), variables are initialized for you (Again I think). In Release optimizations are included but uninitialized variables will often just contain whatever junk is in the memory allocated at the time.

For me at least, most 'bugs' I have in Release Mode are either because of not initializing a variable then using it (and it contains junk) or due to the compiler changing memory padding of for example a struct.

Share this post


Link to post
Share on other sites
Yeah mark another one up for variable initialization (or lack thereof). Has caused me some problems in the past.

Share this post


Link to post
Share on other sites
Aha! All because of one uninitialized variable. I guess it was causing problems if the variable happened to be initialized to a garbage negative value. That's my theory anyway.

Thanks for helping me out! I didn't know debug mode gave those little bits of "help". I kinda feel like debug mode shouldn't do that because then you don't see the mistakes you've made. Oh well, now I know.

Share this post


Link to post
Share on other sites
Quote:
Original post by grekster
Yeah mark another one up for variable initialization (or lack thereof). Has caused me some problems in the past.

I don't want to hijack the thread, but I'm curious to know what the benefit of debug mode initializing your variables is. If I need to initialize a variable, but have forgotten to, then isn't it better for me to know when I test in debug mode that there is a problem, since the whole point is to get rid of bugs (hence the name)? I compile in release mode whenever I can...

Share this post


Link to post
Share on other sites
Quote:
Original post by bschneid
If I need to initialize a variable, but have forgotten to, then isn't it better for me to know when I test in debug mode that there is a problem, since the whole point is to get rid of bugs (hence the name)? I compile in release mode whenever I can...


Turn your compiler warnings all the way up, you should get warnings anywhere you use a potentially uninitialized variable.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!