5

Delphi documentation says that "Debug information [...] it does not affect the size or speed of the executable program."

However, when I activate Debug information (in Project Options -> Linker) my EXE goes from 1.8MB to 7MB. What am I doing wrong?


Note: I suppose that the 'Debug information' under 'Linking' is the same as 'Debug information' under 'Compiling' since they have the same compiler directive ( {$D} ).

Gabriel
  • 20,797
  • 27
  • 159
  • 293
  • Update related to Delphi XE7 http://stackoverflow.com/questions/27931285/full-debugging-information-generates-huge-exe-files – Gabriel Jan 13 '15 at 21:25

2 Answers2

15

Your assumption is incorrect. Compiling with debug information means that the compiler generates DCUs with debug information. Linking with debug information means that the linker puts the debug info from the DCUs into the final binary instead of stripping it out, so of course that will make the binary a lot bigger.

Linking without debug info is usually OK, since the debugger can get at the debug info in the DCUs as long as it can find them. But if you need to debug your app in some scenario where the DCUs won't be available, you'll want the link option turned on.

Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
4

Adding debug information won't impact the code size (the code generated is the same with the option on or off, other options control code generation), but will impact the file size.

  • Thaks ldsandon. That was actually my problem. The program was ridiculously large. – Gabriel Jun 08 '11 at 10:30
  • The file could become very large depending if you had built using debug DCUs, or if you have many and very large DCUs, the linker may eliminate some unused code, but I am not sure it can strip unused debug info. Anyway that's just informations added to the generated file (although many debug DCUs are usually built using different code generation options also, take care...), not to the code. If you use some exception tracing libraries (JCL/JVCL, MadExcept, EurekaLog) they may need debug informations into the file to produce a readable trace, otherwise you will get only numeric addresses. –  Jun 08 '11 at 12:33