.netdebugging

.NET: Running a program with debug information


It's known that compiling a program in "Debug mode" (rather than "release mode") could leads to worse performance.

But sometimes it could be useful to have some debug information. For example, when our program is running on the production server and an exception occurs, it would help to log the stack trace at exception time.

I found this is possible, compiling the code in "release mode" and placing the *.pdb file together with binaries files in the same folder.

Anyone knows if attaching the pdb file leads to any performance problem.


Solution

  • It should not cause any performance issues, since the DLL has been compiled in Release mode. When an exception gets thrown, the .NET VM knows all about your stack trace, including what instruction was running in each method of the stack when the exception got thrown. Including the pdb file just gives it a way to map this data to actual file names and line numbers.

    Any performance difference caused by including this extra data in the stack trace would probably be dwarfed by the overhead of throwing the exception in the first place.