Visual Studio - Debug vs Release

后端 未结 2 1277
遇见更好的自我
遇见更好的自我 2020-12-29 09:19

I built a windows service, targeted for .NET 2.0 in VS 2008. I run it as a console app to debug it.

Console app is working great. I put it on my local computer as a

相关标签:
2条回答
  • 2020-12-29 09:51

    1) It might, if not directly, so indirectly by making the application slower and making it use more memory.

    2) When it runs in debug mode, there are certain things that works differently, for example:

    • The code is compiled with some extra NOP instructions, so that there is at least one instruction at the beginning of each code line, so that it will be possible to place a break point at any line.

    • The instructions can be rearranged in release mode, but not in debug mode, so that the code can be single stepped and the result will correspond to the exact order of the source code.

    • The garbage collector works differently, by letting references survive throughout their entire scope instead of only for the time that they are used, so that variables can be viewed in debug mode without going away before the scope ends.

    • Exceptions contain more information and takes a lot longer to process when thrown.

    All those differences are relatively small, but they are actual differences and they may matter in some cases.

    If you see a great difference in performance between debug mode and release mode, it's usually because there is something wrong with the code, like for example if it's throwing and catching a huge amount of exceptions. If there is a race condition in the code, it may only happen in release mode because there is some extra overhead in debug mode that makes the code run slightly slower.

    3) As to what the problem with your service is, I don't know, but it doesn't seem to be related to how the code is executed in debug mode or release mode. The code would start in any case, and if it was a problem with the code, it would crash and you would be able to see it in the event log.

    0 讨论(0)
  • 2020-12-29 10:07

    I'm not sure I can speak to #1 or #2, but when I've had problems like that, it was because of incorrect threading/concurrency. I'm not sure how large your app is, but that might be a good place to start.

    0 讨论(0)
提交回复
热议问题