c# interview question :- Debug VS Release ( c# training )

c# interview question :- Debug VS Release ( c# training )


In this video will talk about what is the difference between Debug and Release now before i go ahead and talk about Debug and Release let me talk about two important faces or two important things which happens when you develop Dot Net application or software application the first thing what happens is the programmer goes and he write some code he actually goes and develops the application he opens Visual Studio he does the development thing right once a application is developed this code is then pushed to productions so the program goes and he builds that application he takes those DLL or EXE whatever it is and he pushes it to production now Debug and Release are nothing but they are build modes so he will use the Debug mode when you are actually writing a code when you are developing the application and he will use the released mode when you want to go live when you want to push your DLL and EXE or whatever is a fully compile code to production now both of these faces or i will say both of these build modes have they own priority for example when you are in the Debug mode or i will say rather than you are doing development the most important thing for you is Debugging you would like to go and Debug the code properly you would like to go and ensure that you can see the full information what’s happening inside the code so over there you know you are not concern with performance but you are rather concern with Debugging but if you are in the production face or i will say Release node the most important thing for you is not tracking errors but the most important thing for you is running the application as fast as you can in other words performance is your main priority so the biggest difference between Debug and Release mode is that in Debug mode the code is not optimize while in Release mode the code is optimize in order to understand this difference right let’s go and see a simple example now remember that this is the first difference there is one more difference and which i will talk later on but what will do is let’s first try to see that how the code is optimize between Debug and Release so let me just go back to my Visual Studio here so i am going to go and flip back to my Visual studio and what will do here is let me go and create some functions here so i will go and create some methods here like let’s say M1 i will create one more method called as must be M2 and i will create one more method called as M3 and from the main right you called let’s say M1 OK this M1 calles M2 and M2 calls M3 and in M3 what i will do is i will just go and through up exception here i will tell you what exactly i am doing and through up exception is saying some error now if you watch this code very closely let me just make you understand this code first first thing this static void main will Run the main will go and run the M1 function from the M1 function the M2 function is called from the M2 function M3 function is called and inside the M3 function a exception is the raised and this exception is then propagated to the static void main now as a developer when you developing this application we would like to know the complete stack trace of the error you would like to know ok which function was called after that on which function error was and what is the sequence of the calling of those methods so as a developer you would like to get a complete stack trace information so if you go and run this application now in a Debug mode if you do a Ctrl+F5 here and if you watch very closely i will just go and do a zoom here now if you watch very closely here you can see because i have ran that application in a Debug mode he is telling me Yes you know the first thing which ran was this static void main from the static void main then M1 was called M1 then called M2 M2 than called M3 and inside M3 there was a exception so you can see that for a developer he has given a complete stack trace information and that’s what you wont right when you doing development you would like to get complete stack trace information but now if you go and select Release over here if i go and select Release and if i do Ctrl+F5 here now now this is interesting if you watch this closely you can see that he is not displaying the stack trace he just saying that yes some error as acquired and this is what the error is and why this doing is because in Release mode he has to ensure that the application is faster and if you want the application to be faster then he should not be tracking any kind of stack trace information so the biggest difference between Debug and Release mode is that in Debug mode the application is mainly meant for debugging for saying errors while in Release mode the most important priority for the application is performance so that is the first difference that code is optimized in Release mode as compare to the Debug mode now the second important difference is that in Release mode when you go and compile a project in Release mode all the Debug symbol are removed now what do you mean by Debug Symbols now for examples let’s say that you have application here and in this application we say console dot write line let’s say this is application this is your application now many times the developer can go and write some code which is does not want to go and ship in production for example he can write here saying console dot write line just display me date time now just the developer wants to see this date time now but this code he does not want to push in production this code should only run in development so for that what the developer can do is he can use the Debug symbols you can go here and say Debug then only go and use this code now what will happened is this code which is see over here will run only in a debug mode in other word if i go and select debug over here and if i do a Ctrl+F5 here you can see that there is some problem here if Debug this is CAPS so if i do a Ctrl+F5 here you can see i am seeing the date time now here right if i go and change to this Release now if i go and select the Release over here and if i do a Ctrl+F5 you can see the i can not see date and time so the second difference is between Debug and Releases that all these Debug symbols which the developer has put for own benefit or i will say own each is removed when we go and compiled the code in Release mode so two big differences between Debug and Release first one Release code is optimized second one all the Debug symbols which are there during development are removed when you go to the Release mode or when we go live So i hope that you are enjoyed this video in this video we will trying to understand what exactly is a difference between Debug and Release mode in Visual Studio. THANK YOU SO MUCH 🙂

21 thoughts on “c# interview question :- Debug VS Release ( c# training )

  • How can we put debug ON in Prod some sometime to gather logs in terms to identifying the root cause in Production? Obviously we cannot replace the executable files on the server for this…!

  • Nice video, thanks… I'd love to learn more about the different optimization levels between debug and release versions as well, if you have anything more on that. Thanks again for posting this.

  • Debug mode is:
    For debugging, which takes more resources and time to execute because more information should be generated for the programmer like the stack trace information.
    In Release mode:
    It is made for production(used somewhere by someone), the code is optimized and runs faster

    #if DEBUG
    //code
    #endif
    //This will tell the preprocessor to run this code only if it is in debug mode, if it is in release the code will not be included in the program.

  • A stack trace allows to track the sequence of (nested) functions called up to the point where the stack trace is generated.

  • in the real sense debug code has very little to do with "optimization" it simply has additional information plugged in for the developer to do faster development and testing. The second "difference" is more close to the difference between debug and release. Most of the video I see here is very primitive explanation of the author's understanding of C#

  • DEBUG symbols aid developer to gather data about his or her code. It is the meta data available through the development IDE or toolset to aid to quickly spot the states of variables. it also includes traps that allows halts so that the programmer can watch the execution closely. Once the code is developed it has to go through QA before being pushed to the PROD, Once you have met all the requirements to run the code in PROD, you simply have no use for the DEBUG information, so you get rid of them

  • DEBUG has nothing to do with CODE optimization, DEBUG aid in unit testing and development. It is a BURDEN in production, because there is no use for the DEBUG information once the code is certified to be meeting all USE CASES with out a flaw. You should loook at code optimization techniques which is not related to DEBUG or RELEASE as stated in the video.

  • You misunderstood my statement. In fact in *most* IDEs there are different optimization levels between the standard DEBUG and RELEASE builds. For embedded applications (which I am most familiar with) there is typically no optimization (-O0) for debug builds…whereas the standard for release builds is to optimize for size (-Os). So the two build configurations (debug/release) in fact DO differ in optimization levels, by default in most of the IDEs I have used–like Atmel Studio (avr-gcc).

  • Thank you very much.. I really like the way you explained the detail of Debug and Release

    Thousands of Like from my side…

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *