Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug vs Release in optimization of .net (concerns when distributing to users)

Is there any security or performance issues with distributing the Debug vs the Release build to the public?

Most of the time I just pack the .exe file in the Debug folder (along with required dependencies) and give it to users.

Are there any reason to prefer one more than the other to be distributed ?

like image 888
sharp12345 Avatar asked Jan 06 '13 16:01

sharp12345


2 Answers

Yes, of course there are - both security and performance implications.

Debug builds contain more information than release builds and many compiler optimizations are off for debug builds.

Also see Debug/Release difference here.


Are there any reason to prefer one more than the other to be distributed ?

Yes. If you want to have a faster binary that has been compiled with optimizations, use release.

like image 192
Oded Avatar answered Sep 30 '22 15:09

Oded


There is no security issue that I can think of. There is most certainly a performance issue, the Debug build of your assemblies contains an attribute (DebuggableAttribute) that will always prevent the jitter optimizer from optimizing the code. This can make a great deal of difference on the perf of the running program. Optimizations performed by the jitter are documented in this answer.

You could have a problem with memory consumption. The garbage collector will operate differently, keeping local variables alive until the end of the method body. This is a corner case and such a problem should have been diagnosed while testing the app, assuming you used realistic data.

Specific to VB.NET, shipping the Debug build can very easily cause your program to crash with an OutOfMemoryException when it is run on your user's machine without a debugger attached. It fails due to a leak on WeakReferences, used by Edit+Continue to keep track of classes that have an event handler with the WithEvents keyword.

If you don't have a need for the perf enhancements produced by the jitter optimizer and don't ship VB.NET assemblies then there isn't much to worry about.

like image 22
Hans Passant Avatar answered Sep 30 '22 13:09

Hans Passant