Click to See Complete Forum and Search --> : diff between debug version and release version in code generation


pramod_astro
September 5th, 2002, 07:08 AM
hi,

I like to know the difference between executable generated in debug mode and to that of Release mode under VC++ environment. The file size in debug mode is more than file size in release size.
Actually optimisation of code occurs in release mode. But by seeing the file size diff i can't think that much optimisation occurs. I guess the code generated in debug mode contains debug information. if this is the case, is it required to embed the debug info into the executable. Please come up with the full details which takes major role in code generation.

John E
September 5th, 2002, 08:26 AM
There are several differences between the two versions but the big increase in size is because the debug version contains special information to allow your debugger to step through the code. All your source code is converted into machine code because that's the only way your program can run on its target processor. In the debug version though, each small block of machine code contains references that enable your debugger to locate the actual line of source code that originally generated the machine code. This is why you can 'step through' programs and set break points etc in debug mode but not in release mode. This debugging information is huge.

Another important difference is that all variables (in debug mode) are 'cushioned' by a few bytes which are checked by the debugger to make sure your program isn't writing into memory it doesn't own. If it is, you'll see a warning in your output window beginning with the word "Damage". This is usually displayed after the program terminates. Again, this 'cushioning' takes up extra bytes in your program.

CallMeJoe
September 5th, 2002, 11:20 AM
Also realize that if you optimize for speed vs. size, the result will usually be longer due to loop unrolling and inlined code, etc.